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

1 Comments

  1. AttributeError: module 'tensorflow.compat.v2.__internal__.distribute' has no attribute 'strategy_supports_no_merge_call'
    i am getting an error like this
    after i install tensorflow-gpu from here
    https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.7.0-cp39-cp39-win_amd64.whl

    ReplyDelete

if you are not getting it then ask i am glad to help