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

在新的Tensorflow 2.0版本中已经移除了Session这一模块。

tf.compat.v1.Session() 就可以获得与原先相同的输出信息。

其他类似的报错也可使用这种方法:'placeholder',tf.compat.v1.placeholder() 。

 

也可以将Tensorflow的版本降低,用pip安装 pip install tensorflow==1.14。

posted @ 2022-06-17 20:39  格子叶  阅读(190)  评论(0编辑  收藏  举报