tensorflow einsum得到了错误?

问题描述 投票:1回答:1

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

python numpy tensorflow
1个回答
1
投票

这已在PR 25079中修复并合并。

© www.soinside.com 2019 - 2024. All rights reserved.