【发布时间】:2021-07-14 11:48:16
【问题描述】:
我在 TensorFlow 中做了以下简单的计算,惊讶地发现结果与我预期的不一样。 我的代码:
a = tf.constant([[0.2,1],[0.3,0.75]])
b = tf.constant([[0.2,0.1],[0.8,0.2]])
print(tf.square(a)+tf.square(b))
它提供结果:
tf.Tensor(
[[0.08000001 1.01 ]
[0.73 0.6025 ]], shape=(2, 2), dtype=float32)
但是,我本来期望:
tf.Tensor(
[[0.08 1.0 ]
[0.73 0.6025 ]], shape=(2, 2), dtype=float32)
因为这将是我计算的数学正确结果。出了什么问题?
【问题讨论】:
标签: python tensorflow tensor