tensorflow einsum跟踪错误?

时间:2018-12-14 13:55:54

标签: python numpy tensorflow

为什么这些输出不同?这是预期的行为吗?我正在使用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上打开了一个问题,它看起来像个错误。

1 个答案:

答案 0 :(得分:1)

此问题已在PR 25079中修复并合并。