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

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有两个实现模块,分别是​​keras​​​和​​tensorflow.keras​​​这两个模块一般情况下是可以相互转换的,前者的函数都可以换成第二个运行,但是第二个模块中的有些函数API在​​keras​​中没有实现

解决方案:
​​​import keras​​​换成​​from tensorflow import keras​

from tensorflow import keras