[英]different results between tf.matmul and np.matmul
考虑以下(在 colab 上运行):
a = np.array([
[ 0.9951848 +0.09801677j, 0.77301085+0.6343928j , 0.29028502+0.95694023j ],
[-0.55557 +0.8314698j , -0.83146954+0.5555703j , -0.98078525+0.19509049j],
[-0.47139683-0.88192123j, -0.29028472-0.9569403j , -0.09801722-0.9951847j ]
], dtype=np.complex64)
x = np.matmul(a, a.conj().T)
a_tf = tf.convert_to_tensor(a)
x_tf = tf.matmul(a_tf, tf.transpose(tf.math.conj(a_tf)))
x == x_tf
这会产生不同的结果:
<tf.Tensor: shape=(3, 3), dtype=bool, numpy=
array([[ True, True, False],
[ True, True, False],
[ True, True, False]])>
tf.matmul
和np.matmul
的输入是相等的。 对此有合乎逻辑的解释吗?
结果相同,直到第 6 位。 尝试像这样比较:
np.testing.assert_almost_equal(x, x_tf.numpy(), decimal=6)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.