解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘

简介: 解决AttributeError: module ‘keras.utils‘ has no attribute ‘plot_model‘

2022-01-01 19:41:58.347964: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
  File "E:/Code/PyCharm/TensorFlow学习/Keras/多输入多输出.py", line 36, in <module>
    keras.utils.plot_model(model, "multi_input_and_output_model.png", show_shapes=True)
AttributeError: module 'keras.utils' has no attribute 'plot_model'

出现问题原因:

报错原因是keras.utils模块下没有plot_model这个函数,keras有两个实现模块,分别是kerastensorflow.keras这两个模块一般情况下是可以相互转换的,前者的函数都可以换成第二个运行,但是第二个模块中的有些函数API在keras中没有实现

解决方案:

import keras换成from tensorflow import keras

from tensorflow import keras


目录
相关文章
|
3月前
|
TensorFlow 算法框架/工具
【Tensorflow】解决A `Concatenate` layer should be called on a list of at least 2 inputs
在TensorFlow 2.0中,使用Concatenate函数时出现错误,可以通过替换为tf.concat 来解决。
41 4
|
3月前
|
TensorFlow API 算法框架/工具
【Tensorflow+keras】解决使用model.load_weights时报错 ‘str‘ object has no attribute ‘decode‘
python 3.6,Tensorflow 2.0,在使用Tensorflow 的keras API,加载权重模型时,报错’str’ object has no attribute ‘decode’
53 0
Can‘t get attribute ‘SiLU‘ on <module ‘torch.nn.modules.activation‘
Can‘t get attribute ‘SiLU‘ on <module ‘torch.nn.modules.activation‘
AttributeError: module ‘torch.utils‘ has no attribute ‘data‘
属性错误:模块的'torch.utils'没有属性'data'
96 0
|
TensorFlow 算法框架/工具
成功解决AttributeError: module 'tensorflow.python.keras' has no attribute 'Model'
成功解决AttributeError: module 'tensorflow.python.keras' has no attribute 'Model'
|
Python
numpy 报错:”AttributeError: module ‘numpy‘ has no attribute ‘bool‘“
numpy 报错:”AttributeError: module ‘numpy‘ has no attribute ‘bool‘“
2276 0
|
TensorFlow API 算法框架/工具
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
169 0
解决AttributeError: module ‘tensorflow‘ has no attribute ‘div‘
|
TensorFlow 算法框架/工具
TF版本升级问题:成功解决AttributeError: module tensorflow has no attribute mul
TF版本升级问题:成功解决AttributeError: module tensorflow has no attribute mul
TF版本升级问题:成功解决AttributeError: module tensorflow has no attribute mul
|
算法框架/工具 Windows