解决AttributeError: module ‘keras‘ has no attribute ……

慈云数据 8个月前 (03-13) 技术支持 114 0

在成功解决AttributeError: module ‘keras‘ has no attribute ‘utils‘_new1998的博客-CSDN博客这篇博客中博主有提到如何解决这一问题,其中就是要把

解决AttributeError: module ‘keras‘ has no attribute ……
(图片来源网络,侵删)
IMPort keras

更改成为

from tensorflow import keras

而博主不知道其中原因,原因其实是在TensorFlow 2.4及以上版本中,import keras的方式已经被弃用,取而代之的是import tensorflow.keras,它是Keras和TensorFlow的官方集成版本。所以在终端使用如下代码来检查一下你的tf和keras版本吧。 

解决AttributeError: module ‘keras‘ has no attribute ……
(图片来源网络,侵删)
import tensorflow as tf
import keras
print(tf.__version__)
print(keras.__version__)
微信扫一扫加客服

微信扫一扫加客服

点击启动AI问答
Draggable Icon