【深度学习】Tensorflow报错:AttributeError: module ‘tensorflow‘ has no attribute ‘InteractiveSession‘
【深度学习】Tensorflow:AttributeError: module 'tensorflow' has no attribute 'InteractiveSession'在运行Tensorflow时报错:AttributeError: module 'tensorflow' has no attribute 'InteractiveSession'这其实不是包的安装错误,是因为在新的Te
文章共277字 · 阅读需要大约1分钟
一键AI生成摘要,助你高效阅读
问答
·
【深度学习】Tensorflow:AttributeError: module 'tensorflow' has no attribute 'InteractiveSession'
在运行Tensorflow时报错:
AttributeError: module 'tensorflow' has no attribute 'InteractiveSession'
这其实不是包的安装错误,是因为在新的Tensorflow 2.0版本中已经移除了Session这一模块,改换运行代码:
sess = tf.InteractiveSession()
换成:
sess = tf.compat.v1.InteractiveSession()
同理,如果代码中还有类似的" tf.*** “之类的代码,应该都要在其后加上"compat.v1.
”。
AttributeError: module 'tensorflow' has no attribute 'squared_difference'
AttributeError: module 'tensorflow' has no attribute 'global_variables_initializer'
如果用着不习惯,那就降低Tensorflow的版本也可以:
pip install tensorflow==1.14
更多推荐
已为社区贡献19条内容
所有评论(0)