奇异值分解(Singular Value Decomposition,SVD)是一种矩阵分解(Matrix Decomposition)的方法。除此之外,矩阵分解还有很多方法,例如特征分解(Eigendecomposition)、LU分解(LU decomposition)、QR分解(QR decomposition)和极分解(Polar decomposition)等。这篇文章主要说下奇异值分解,这个方法在机器学习的一些算法里占有重要地位。
参考自维基百科。
下面引用 SVD 在维基百科中的定义。
In linear algebra, the singular value decomposition (SVD) is a factorization of a real or complex matrix. It is the generalization of the eigendecomposition of a positive semidefinite normal matrix (for example, a symmetric matrix with positive eigenvalues) to any m×n m\times n matrix via an extension of polar decomposition.
也就是说 SVD 是线代中对于实数矩阵和复数矩阵的分解,将特征分解从 半正定矩阵 推广到任意 m×n m\times n 矩阵。
注意:本篇文章内如未作说明矩阵均指实数矩阵。
假设
那么可以计算得到
接下来就是求这个矩阵的特征值和特征向量了
Python 中可以使用 numpy 包的 linalg.svd()
来求解 SVD。
import numpy as np
A = np.array([[2, 4], [1, 3], [0, 0], [0, 0]])
print(np.linalg.svd(A))
输出
(array([[-0.81741556, -0.57604844, 0. , 0. ],
[-0.57604844, 0.81741556, 0. , 0. ],
[ 0. , 0. , 1. , 0. ],
[ 0. , 0. , 0. , 1. ]]),
array([ 5.4649857 , 0.36596619]),
array([[-0.40455358, -0.9145143 ],
[-0.9145143 , 0.40455358]]))
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有