- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
scipy.linalg.svd将“任意”数组 A 分解为 U、s、VT一个例子是:
from numpy import array
from scipy.linalg import svd
import numpy as np
# define a matrix
A = np.arange(200).reshape((100,2))
print ('A.shape',A.shape)
U, s, VT = svd(A)
print ('U.shape',U.shape)
print ('s.shape',s.shape)
print ('VT.shape',VT.shape)
s_diag = np.zeros((100,2))
np.fill_diagonal(s_diag, s)
print(np.allclose(A,np.dot(np.dot(U,s_diag),VT)))
当A.shape == (m,n)
时,数组U和VT的默认形状为and (m,m)和(n,n)。我注意到有一个选项(full_matrices
)符合我的期望,例如: 我无法理解的是为什么 U 和 VT 需要是 (m,m) 和 (n,n)? 相乘时,由于 s_diag 是“对角线”,因此 U 和 VT 的唯一部分无论如何,使用的 VT 表都较小...(例如,在示例中,U 的大小可能只是 100,2...)
最佳答案
经过一些wikipedia reading和一些数学内存,事实证明这是有充分理由的......
因此,第一个明显的原因是,根据 m 或 n 中较小的一个,其中一个表无论如何都需要填满。
现在数学原因是在数学理论中 U 和 VT 都是 orthonormal ,这意味着 np.dot(U,U.T)
等于 np.dot(U.T,U)
等于单位矩阵。 VT 也是如此。因此它们的形状为 (m,m) 和 (n,n)
这似乎对我的情况没有用,我想进行降维,但 SVD 还有许多其他用途,例如查找伪逆表。
关于python - scipy.linalg.svd : shapes of VT and U: what is full_matrices and why is it needed?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54987801/
scipy.linalg.svd将“任意”数组 A 分解为 U、s、VT一个例子是: from numpy import array from scipy.linalg import svd impo
我是一名优秀的程序员,十分优秀!