为什么 tensorflow 和 numpy 的特征值输出不同?
Why the eigenvalue output is different for tensorflow and numpy?
我尝试同时使用 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})
我尝试同时使用 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})