AttributeError: module 'tensorflow' has no attribute 'Session' 错误

在使用TensorFlow 2.0最新版本时报错:

	AttributeError: module 'tensorflow' has no attribute 'Session'

原因

  • 其实并不是不是安装错误,是因为在新的Tensorflow 2.0版本中已经移除了Session这一模块。

解决方法

运行下面代码替换tf.Session()即可

>>>	tf.compat.v1.Session()
发布了13 篇原创文章 · 获赞 8 · 访问量 1731

猜你喜欢

转载自blog.csdn.net/qq_30722795/article/details/103181158