AttributeError: module ‘tensorflow‘ has no attribute ‘get_default_graph‘

Posted 时光-ing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AttributeError: module ‘tensorflow‘ has no attribute ‘get_default_graph‘相关的知识,希望对你有一定的参考价值。

解决办法:
(1)报错版本:

from keras.models import Sequential
from keras.layers import Dense, Flatten, LSTM,Dropout

(2)修改版本–使用TensorFlow的实现,而不是直接使用keras

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Flatten, LSTM,Dropout

以上是关于AttributeError: module ‘tensorflow‘ has no attribute ‘get_default_graph‘的主要内容,如果未能解决你的问题,请参考以下文章

AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/home/yolov5/models/comm

unittest模块在linux报错: AttributeError: module 'unittest' has no attribute 'TestRunner'(

AttributeError:模块“tensorflow”没有属性“app”

新的 Kivy 安装:AttributeError: 'module' 对象没有属性 'require'

AttributeError: Can‘t pickle local object ‘Stage.__init__.<locals>.<lambda>‘

AttributeError: Can‘t pickle local object ‘Stage.__init__.<locals>.<lambda>‘