Introduction to errors
Error message:
AttributeError: module ‘tensorflow’ has no attribute ‘Session’
When installing tensorflow using conda install tensorflow-gpu, the version was not specified, resulting in the installation of tensorflow2.1 version. And tf.Session is the code in version 1.X of tensorflow.
Comparison of tensorflow 1.x and 2.x function interfaces
https://docs.google.com/spreadsheets/d/1FLFJLzg7WNP6JHODX5q8BDgptKafq_slHpnHVbJIteQ/edit#gid=0
Solution
- Method: Use the interface of tensorflow 2.x version to call
tf.Session() --> tf.compat.v1.Sesion() - Method: Use the previous version.
reference:
AttributeError: module ‘tensorflow’ has no attribute ‘Session’