AttributeError:模块“tensorflow”没有属性“Session”
环境配置:
python3.7
tensorflow2.0
Window 10
初始代码:
# Launch the graph in a session.
with tf.Session() as sess:
# Run the variable initializer.
sess.run(init)
# ...you now can run ops that use the value of 'w'...
执行错误:
错误原因:
是因为tf2.0中已经将tf.Session( )改为了tf.compat.v1.Session( )
解决方法:
with tf.compat.v1.Session() as sess:
# Run the variable initializer.
sess.run(init)
# ...you now can run ops that use the value of 'w'...