Equations · Standard linear algebra (Beltrami 1873, Jordan 1874); Eckart and Young (1936) for low-rank approximation
The singular value decomposition (SVD), explained
Every matrix, of any shape, factors into a rotation, a scaling along the axes, and another rotation. The SVD also writes the matrix as a sum of rank-one pieces, ordered by importance; keeping the first gives the best rank- approximation. It underlies PCA, low-rank compression and LoRA's motivation.
Term by term
Any matrix.
Orthogonal matrices (, ). Their columns and are the left and right singular vectors.
A diagonal matrix of singular values. Here is a matrix, not a sum and not a covariance.
The -th singular value: non-negative, sorted so . Not a standard deviation. are the eigenvalues of .
The same matrix as a sum of rank-one outer products, where is the rank of . Truncating the sum at terms gives the closest rank- matrix in the Frobenius and spectral norms.
Shapes
- Full SVD: , , .
- Thin SVD (what code returns with full_matrices=False): , , with .
A small worked example
has rank 1. Its SVD has , , , . Check: .
In code
import numpy as np
A = np.array([[2.0, 2.0], [1.0, 1.0]])
U, S, Vt = np.linalg.svd(A, full_matrices=False) # S: singular values, sorted
k = 1
A_k = (U[:, :k] * S[:k]) @ Vt[:k] # best rank-k approximationEvery symbol in it
Other equations
- Scaled dot-product attention
- Softmax
- Cross-entropy loss
- Adam update
- Layer normalization
- RMSNorm
- The ELBO
- KL divergence
- Backpropagation through one layer
- LoRA
- GELU
- Dropout
- Batch normalization
- Rotary position embedding (RoPE)
- Multi-head attention
- PPO clipped objective
- DPO loss
- Policy gradient (REINFORCE)
- Bellman equation
- Q-learning update
- InfoNCE contrastive loss
- Diffusion forward process
- DDPM simplified loss
- VAE reparameterization trick
- GAN minimax objective
- AdamW
- Cosine learning-rate schedule
- Perplexity
- Logistic regression
- Normal equation (linear regression)
- Principal component analysis (PCA)