成功的案列: import tensorflow as tf tf.compat.v1.disable_eager_execution() message=tf.constant('hello world') with tf.compat.v1.Session() as se: print(se.run(message).decode())
失败的总结:
import tensorflow as tf
message=tf.constant('hello world')
with tf.Session() as se:
print(se.run(message).decode())
会出现第一个问题:如下
解决办法:是因为tensorflow 升级后抛弃掉了这种写法== tf.Session() as se: 改写成 with tf.compat.v1.Session() as se:
第二个问题:
解决办法:
增加tf.compat.v1.disable_eager_execution() 即可解决 (版本问题引起的)