错误简介
错误提示:
AttributeError: module ‘tensorflow’ has no attribute ‘Session’
使用conda install tensorflow-gpu安装tensorflow时未指定版本,导致安装了tensorflow2.1版本。而tf.Session是1.X版本tensorflow中的代码。
tensorflow 1.x 和2.x 函数接口对比
https://docs.google.com/spreadsheets/d/1FLFJLzg7WNP6JHODX5q8BDgptKafq_slHpnHVbJIteQ/edit#gid=0
解决方法
- 方法: 使用tensorflow 2.x版本的接口进行调用
tf.Session() --> tf.compat.v1.Session() - 方法:使用以前的版本。
参考:
AttributeError: module ‘tensorflow’ has no attribute ‘Session’