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

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

    import tensorflow as tf
    sess = tf.Session()
    

    this code will show an Attribute error on version 2.x

    to use version 1.x code in version 2.x

    try this

    import tensorflow.compat.v1 as tf
    sess = tf.Session()
    

提交回复
热议问题