liveBook · Manning

Singular value decomposition

As explained in Math and Architectures of Deep Learning

The statement that any matrix can be decomposed as a product of orthogonal matrices and a diagonal matrix in singular value decomposition form.

Singular value decomposition (SVD) factors any m × n matrix, square or rectangular, as A = UΣVᵀ. U and V are orthogonal; Σ is diagonal and orders singular values from largest to smallest. This factorization makes a general matrix easier to analyze and compute with. section 4.5 section 4.7

Equation 4.11

A = UΣVT

The central SVD factorization separates a matrix into two orthogonal changes of basis and a diagonal scaling matrix. section 4.5

The right singular vectors are eigenvectors of AᵀA and fill V; the left singular vectors are eigenvectors of AAᵀ and fill U. Both AᵀA and AAᵀ are symmetric positive semidefinite, so their eigenvalues are nonnegative and their eigenvectors are orthogonal. For a nonzero eigenvalue λᵢ of AᵀA, the matching left singular vector is obtained by scaling Av̂ᵢ by 1/√λᵢ. section 4.5.1 section 4.5.2

SVD exposes useful matrix structure:

  • Rank equals the number of nonzero singular values, linking degeneracy to linear dependence among rows or columns. section 4.5.5
  • Extra singular-vector columns in a rectangular factorization can vanish because their corresponding entries in Σ are zero. section 4.5.2
  • Large and small singular values distinguish high-variation directions from weaker variation that may be noise. section 4.6.4 section 4.7

To solve A x = b, first rotate b with Uᵀ, divide by the diagonal entries of Σ, then rotate back with V. For invertible square matrices this agrees with inverse-based solving; for nonsquare systems it yields the Moore-Penrose inverse solution, described as the best-effort approximation. The diagonal and orthogonal factors make these substeps simple, while avoiding direct inversion of A. section 4.5.4 section 4.5.6

Solving systems in PyTorch

`torch.linalg.svd(A)` returns `U`, singular values `S`, and `V_t`. Form a diagonal inverse from `1 / S`, then compute `V_t.T @ (S_inv @ (U.T @ b))`. An invertible 3 × 3 test system produces `[1.0, 2.0, 3.0]` through both matrix inversion and SVD; an overdetermined system likewise matches `torch.linalg.pinv(A)`. section 4.5.6

For mean-subtracted data matrix X with instances as rows, XᵀX is its covariance matrix. Because V contains eigenvectors of XᵀX, SVD computes PCA: columns of V give principal vectors, while diagonal values in S give principal values. Retaining directions with larger variation supports lower-dimensional, relatively noise-free representations. section 4.5.3 section 4.5.7 section 4.7

SVD also supports latent semantic analysis (LSA). Applied to a document-term matrix, it identifies principal directions interpreted as topics. Projecting documents onto topic axes can capture indirect similarity, such as an association between documents using “gun” and “violence” even when they share no term directly. section 4.6.2 section 4.6.4

How Math and Architectures of Deep Learning covers it

How deep it goes
Derives the factorization through positive-semidefinite and orthogonality lemmas, then implements PCA and system solving in PyTorch.
Examples
Uses PyTorch inverse-versus-SVD solvers, pseudo-inverse comparison, direct-versus-SVD PCA, and a correlated document-term dataset for LSA.
What it assumes
Builds on eigenvalues, eigenvectors, orthogonality, positive semidefiniteness, and matrix multiplication while deriving the SVD theorem.
What you can do after
Apply it via PyTorch to solve linear systems and compute PCA or LSA-related decompositions.
How it connects
Connects SVD to eigenvectors, orthogonal matrices, matrix rank, Moore-Penrose inverse, PCA, dimensionality reduction, and latent semantic analysis.

Also explained in

Compare how 6 books explain singular value decomposition →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math and Architectures of Deep Learning. The section links point to the parts of the book it draws on.