成功解决:AttributeError: module ‘tensorflow‘ has no attribute ‘Session‘

from 陆羽飞

import tensorflow as tf
tf.Session()

报错AttributeError: module ‘tensorflow’ has no attribute ‘Session’。这其实不是安装错误,是因为在新的Tensorflow 2.0版本中已经移除了Session这一模块。

tf.Session()之前加代码:tf.compat.v1.Session()即可。

猜你喜欢

转载自blog.csdn.net/shine_00/article/details/121015971