scipy.linalg.svd:VT和U的形状:什么是full_matrices,为什么需要它?

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

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)))

enter image description here.png

A.shape == (m,n)时,数组U和VT的默认形状是和(m,m)和(n,n)。我注意到有一个选项(full_matrices)可以达到我的预期,例如:enter image description here我无法理解为什么U和VT需要(m,m)和(n,n)?当乘以时,由于s_diag是“对角线”,因此使用的U和VT表的唯一部分是较小的......(例如在U的大小中,U的大小可能只有100,2 ...)

python scipy svd
1个回答
1
投票

经过一些wikipedia reading和一些数学回忆后,事实证明这是有正当理由的......

因此,首先显而易见的原因是,根据哪一个较小,m或n,其中一个表格无论如何都需要填满。

现在数学原因是数学理论U和VT都是orthonormal,意味着np.dot(U,U.T)等于np.dot(U.T,U)等于单位矩阵。 VT也是如此。因此它们具有形状(m,m)和(n,n)

这似乎对我的情况没有用,我希望减少维数,但SVD有许多其他用途,例如查找伪逆表。

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