【发布时间】:2019-11-12 09:32:25
【问题描述】:
a = tf.compat.v1.constant(5.0)
b = tf.compat.v1.constant(6.0)
sum1 = a + b
g = tf.compat.v1.Graph()
with g.as_default():
# Define operations and tensors in `g`.
hello = tf.compat.v1.constant('hello')
assert hello.graph is g
sess = tf.compat.v1.Session(graph=g)
print(sess.run(sum1))
tensorflow-gpu2.0 我不知道为什么。我是张量流的初学者
【问题讨论】:
-
您能否详细说明您面临的问题?很暧昧
-
请阅读一些教程(如 this)以熟悉 TensorFlow。在版本 2.x 中,eager execution 默认启用,因此,正如错误指出的那样,您不能使用图形和会话。您可以禁用 Eager Execution 并返回到 1.x 的处理方式,但如果您刚开始使用 TensorFlow,您可能最好学习 2.x 并使用它。
-
import tensorflow.compat.v1 as tf and tf.disable_v2_behavior() 试试这个并检查一次。
标签: python tensorflow