gpt4 book ai didi

python - 为什么 tensorflow 和 numpy 的特征值输出不同?

转载 作者:行者123 更新时间:2023-11-28 20:40:36 25 4
gpt4 key购买 nike

我尝试同时使用 numpy 和 tensorflow 计算矩阵的特征值,但我为每个实现获得了不同的特征值。以下是详细信息

A=([1,2,3],[1,2,3],[1,2,3]) 

带有 numpy 的 A 的特征值是 [0,6,0]

使用 tensorflow 的 A 的特征值为 [ 0.30797836, 0.64310414, 5.04891825]

我使用 tf.self_adjoint_eig 实现 tensorflow,使用 numpy.linalg.eig 实现 numpy。

最佳答案

根据功能描述: https://www.tensorflow.org/versions/master/api_docs/python/math_ops.html#self_adjoint_eig

Calculates the Eigen Decomposition of a square Self-Adjoint matrix.

Only the lower-triangular part of the input will be used in this case. The upper-triangular part will not be read.

因此 TensorFlow 的 self_adjoint_eig 在你的矩阵上等价于 numpy 的 eig 下面的矩阵

({1,1,1},{1,2,2},{1,2,3})

关于python - 为什么 tensorflow 和 numpy 的特征值输出不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35498852/

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