TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Singular Value Decomposition for Programmers

119 点作者 disaster01超过 7 年前

4 条评论

tw1010超过 7 年前
One of my favourite ways to understand the SVD is like this.<p>Think about the x-y plane, and imagine that we&#x27;ve drawn out the unit circle centered at the origin. Now imagine we have some matrix A that we apply to each point in the plane. Thus points will go here and there and you could visualize this effect, if you want, as producing a sort of vector field drawn above the plane where the start of each arrow is the original position of a point and the end of each arrow is where the matrix A moved it. A cute thing about matrices is that it can only do one of three things to the unit circle. It can either collapse the unit circle into a point (which happends only if A is the zero matrix), or it can transform it into a line, or it can transform it into an ellipse. Other functions could possibly transform the circle into some other shape, but matrices are constrained enough that they can only do one of these three things to it.<p>Now for the SVD. Here&#x27;s the thing. Basically the SVD gives you information about the ellipse at the output of the matrix. You apply <i>numpy.linalg.svd</i> to your matrix and how can you understand what it gives you? Essentially it gives you information about the semi-axes of that ellipse.<p>The first column of the &quot;U&quot; matrix is a vector that start at the origin and extend out towards the first (biggest) semi-axis. The second column extend out to the second largest semi-axis, and so on. But they are all normalized so they don&#x27;t actually touch the semi-axes, they only point towards them. The values in the diagonal of the middle matrix (often denoted Σ) in the SVD (called &quot;singular values&quot;) contains the length of the semi-axes. If all of them are 1 then the matrix did not change the size of the circle one bit.<p>From this intuitive description follows a lot of the properties mentioned in the article. For instance, want to know if the matrix is invertible? Just check out the singular values. If one of them is zero (or near zero since the algorithm for computing the SVD often only gives you an approximate result) then that means the ellipse at the output is collapsed down one dimension, which means it is definitely not invertible since there are a bunch of points which are mapped to the zero vector, and there is no way to figure out where those points should map back to if you wanted to create an inverse function.<p>By the way, if you want to learn more, go check out Boyds course on linear dynamical systems[1]. That&#x27;s essentially where I stole this explanation from.<p>[1] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ZNQ_pBCtYDg" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ZNQ_pBCtYDg</a>
评论 #15445380 未加载
评论 #15444620 未加载
评论 #15445937 未加载
cglouch超过 7 年前
Jeremy Kun also has a couple good articles about SVD:<p><a href="https:&#x2F;&#x2F;jeremykun.com&#x2F;2016&#x2F;04&#x2F;18&#x2F;singular-value-decomposition-part-1-perspectives-on-linear-algebra&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jeremykun.com&#x2F;2016&#x2F;04&#x2F;18&#x2F;singular-value-decompositio...</a><p><a href="https:&#x2F;&#x2F;jeremykun.com&#x2F;2016&#x2F;05&#x2F;16&#x2F;singular-value-decomposition-part-2-theorem-proof-algorithm&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jeremykun.com&#x2F;2016&#x2F;05&#x2F;16&#x2F;singular-value-decompositio...</a><p>The first one is particularly helpful for understanding SVD conceptually.
评论 #15444334 未加载
dragandj超过 7 年前
Useful links to the library used in the article:<p>source code: <a href="http:&#x2F;&#x2F;github.com&#x2F;uncomplicate&#x2F;neanderthal" rel="nofollow">http:&#x2F;&#x2F;github.com&#x2F;uncomplicate&#x2F;neanderthal</a><p>and the documentation: <a href="http:&#x2F;&#x2F;neanderthal.uncomplicate.org" rel="nofollow">http:&#x2F;&#x2F;neanderthal.uncomplicate.org</a>
amelius超过 7 年前
Note that computing the SVD of an m<i></i>*n matrix is O(mn^2) with m&lt;=n.<p>So never try to do this for large square matrices. (Just like you should never compute the inverse of a large matrix).<p>Even for large non-square matrices, computing the SVD can be prohibitively expensive.
评论 #15445721 未加载