gpt4 book ai didi

python - tensorflow einsum 的跟踪错误吗?

转载 作者:行者123 更新时间:2023-12-01 08:34:37 25 4
gpt4 key购买 nike

为什么这些输出不同?这是有意的行为吗?我使用的是 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com