Tensorflow 2.0 - AttributeError: module 'tensorflow' has no attribute 'Session'

前端 未结 10 1237
小鲜肉
小鲜肉 2020-12-02 05:41

When I am executing the command sess = tf.Session() in Tensorflow 2.0 environment, I am getting an error message as below:

Traceback (most recent         


        
10条回答
  •  遥遥无期
    2020-12-02 06:27

    If this is your code, the correct solution is to rewrite it to not use Session(), since that's no longer necessary in TensorFlow 2

    If this is just code you're running, you can downgrade to TensorFlow 1 by running

    pip3 install --upgrade --force-reinstall tensorflow-gpu==1.15.0 
    

    (or whatever the latest version of TensorFlow 1 is)

提交回复
热议问题