SVD 公式:
M
=
U
Σ
V
T
M = UΣV^T
M=UΣVT。
我们以二维空间为例,通过观察解释为什么U和V一定存在。
在二维空间里 SVD 需要找到2个互相垂直的单位向量(就是U),在经过M的转化(相乘)后依然互相垂直(就是V)。
这个2个互相垂直的单位向量一定位于一个半径为1的圆上。
那么个圆在经过M的空间转换后会是什么形状呢,答案是:一个椭圆。
当 M = [[0.5, -1], [2, -0.5]]
时,我们可以观察到左边的圆转化成了右边的椭圆:
左边的圆变为右边的椭圆可以拆分成三步:
- 放大/缩小圆
- 旋转/翻转圆
- 从某一角度压扁圆成椭圆
这里只有压扁操作会让椭圆上出现固定的互相垂直的向量,那就是椭圆的最长半径和最短半径,也就是我们要找的转化后的2个向量。反过来我们也一定能在左边的圆上找到对应的2个向量。
延伸
那么为什么U和V可以用来表达M所携带的信息呢?
这是因为U和V都是正交基,他们在空间转换上的效果只有旋转和翻转,也就意味着他们不会改变原空间中"物体"的形状。形状就是信息的表达。
而Σ仅仅是放大/缩小了各个坐标,就跟我们将数据normilize不会导致信息丢失是一样的。
所以U在跟Σ和V相乘之后,并没有带来任何其携带的信息的变化。既然
M
=
U
Σ
V
T
M = UΣV^T
M=UΣVT,那也就意味着U和M携带的信息是一样的。
我们也可以对比理解成将一张图片拉伸/翻转/斜着压扁并不会导致图片上的信息丢失一样,也因为我们进行逆向操作就可以恢复图片。这也意味着V只需要是可逆矩阵就不会影响U表达的信息。
画图的代码: