人工智能必备数学知识学习笔记16:对称矩阵与矩阵的SVD分解

 

  • 完美的对称矩 

     

 

 

 

 

 

 



  • 正交对角化

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



 

  • 什么是奇异值

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



  • 奇异值的几何意

     

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



  • 矩阵的SVD分解

     

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 代码实现:

 

 1.文件 main_svd.py 编写代码:

 1 #矩阵的svd分解
 2 import numpy as np
 3 from scipy.linalg import svd
 4 
 5 if __name__ == "__main__":
 6 
 7     A = np.array([[1, 2],
 8                   [3, 4],
 9                   [5, 6]])
10 
11     U, s, VT = svd(A) #svd分解
12     print(U)
13     print(s)
14     print(VT)
15     print()
16 
17     Sigma = np.zeros(A.shape)#Sigma矩阵
18     for i in range(len(s)):
19         Sigma[i][i] = s[i]
20     print(Sigma)
21     print(U.dot(Sigma).dot(VT))#验证svd(奇异值)分解

2.文件 main_svd.py 运行结果:

 1 /Users/liuxiaoming/PycharmProjects/LinearAlgebra/venv/bin/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py --mode=client --port=49318
 2 import sys; print('Python %s on %s' % (sys.version, sys.platform))
 3 sys.path.extend(['/Users/liuxiaoming/PycharmProjects/LinearAlgebra'])
 4 PyDev console: starting.
 5 Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18) 
 6 [Clang 6.0 (clang-600.0.57)] on darwin
 7 >>> runfile('/Users/liuxiaoming/PycharmProjects/LinearAlgebra/main_svd.py', wdir='/Users/liuxiaoming/PycharmProjects/LinearAlgebra')
 8 [[-0.2298477   0.88346102  0.40824829]
 9  [-0.52474482  0.24078249 -0.81649658]
10  [-0.81964194 -0.40189603  0.40824829]]
11 [9.52551809 0.51430058]
12 [[-0.61962948 -0.78489445]
13  [-0.78489445  0.61962948]]
14 [[9.52551809 0.        ]
15  [0.         0.51430058]
16  [0.         0.        ]]
17 [[1. 2.]
18  [3. 4.]
19  [5. 6.]]
20 Process finished with exit code 0


  • SVD分解的应用

 

 

 

 

 

 

 

 

 

posted @ 2020-09-05 11:45  霜井  阅读(422)  评论(0编辑  收藏  举报