【发布时间】:2019-11-20 16:08:29
【问题描述】:
我正在尝试评估张量的平方。 常数 = tf.constant([1, 2, 3]) tft = 常数*常数
#https://www.tensorflow.org/api_docs/python/tf/compat/v1/Session
sess = tf.compat.v1.Session()
with sess.as_default():
print(tft.eval())
但是,它返回以下错误:
NotImplementedError: 急切执行时不支持 eval 启用,是 .numpy() 你在找什么?
我知道我可以禁用急切的 excuation
将张量流导入为 tf
tf.compat.v1.disable_eager_execution()
constant = tf.constant([1, 2, 3])
tft = constant*constant
print(tft)
但是,这会返回 Tensor("mul_4:0", shape=(3,), dtype=int32) 而不是实际值。请问如何评价?
任何帮助将不胜感激。
【问题讨论】:
标签: session tensorflow2.0