本人使用的tensorflow版本为2.14.0----查询方法
import tensorflow as tf
print(tf.__version__)
(报错)语句:
if __name__ == "__main__":
a = tf.constant([1.0,2.0], name= 'a')
b = tf.constant([2.0,3.0], name= 'b')
result = a+b
print(a.graph is tf.get_default_graph())
修正方法:
在 import tensorflow as tf 后添加 tf.compat.v1.disable_eager_execution()
将 tf.get_default_graph() 改为 tf.compat.v1.get_default_graph()
得到执行结果:True