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

前端 未结 10 1255
小鲜肉
小鲜肉 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:03

    try this

    import tensorflow as tf
    
    tf.compat.v1.disable_eager_execution()
    
    hello = tf.constant('Hello, TensorFlow!')
    
    sess = tf.compat.v1.Session()
    
    print(sess.run(hello))
    

提交回复
热议问题