为什么这些输出不同?这是有意的行为吗?我使用的是 tensorflow 1.12
import tensorflow as tf
matrix = tf.constant([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
with tf.Session() as sess:
print(tf.einsum('ii',matrix).eval())
# 45
同时
import numpy as np
np.einsum('ii',[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
# 15 (as it should be)
为什么tensorflow的einsum要对矩阵的所有元素求和?
更新:我在 GitHub 上打开了一个问题,它看起来像是一个错误。
最佳答案
此问题已修复并合并到 PR 25079 中。
关于python - tensorflow einsum 的跟踪错误吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53781093/