How to fix AttributeError: module 'tensorflow' has no attribute 'Session'

How to fix AttributeError: module 'TensorFlow has no attribute 'Session'


If you have tried to run tensorflow 1.0 version code in while installing tensorflow 2.0 you see some error like this . 

The reason is that session is removed in tensorflow 2.0 they have brute execution in it . So a question arise  how you can solve this problem well there is simple just write these line in your program



import tensorflow.compat.v1 as tf  #(it will import tensorflow 1.0 version in your system)
tf.disable_v2_behaviour() # this line is self explaining i hope this helps you to resolve your problem if you have any kind of query comment



Post a Comment

0 Comments