Spectral Norm
Definition
The spectral norm of a matrix $A$ is its largest singular value:
$$|A|_2 = \sigma_{\max}(A)$$That’s it. Out of all the singular values you get from SVD ($A = U\Sigma V^T$), the spectral norm just picks out the biggest one, $\sigma_1$.
Equivalent definitions that are worth keeping in your head simultaneously, because each one is useful in a different context:
- Operator definition: $|A|_2 = \max_{x \neq 0} \dfrac{|Ax|_2}{|x|_2} = \max_{|x|_2 = 1} |Ax|_2$
- Eigenvalue definition: $|A|_2 = \sqrt{\lambda_{\max}(A^T A)}$ (largest eigenvalue of $A^TA$, then square root)
- SVD definition: largest singular value of $A$
These three are the same number. The operator definition is the one that actually tells you what’s going on physically.
Intuition
Think of $A$ as a machine that takes in vectors and spits out other vectors. If you feed it every unit vector (every direction on the unit sphere), the outputs trace out an ellipsoid. The spectral norm is the length of the longest axis of that ellipsoid β i.e. the maximum possible stretching factor $A$ can apply to any input direction.
So: spectral norm = worst-case amplification factor of the linear map.
This is different from the Frobenius norm, which is basically “add up all the energy in the matrix entries” ($|A|_F = \sqrt{\sum_{ij} A_{ij}^2}$). Frobenius norm cares about the whole matrix’s magnitude. Spectral norm only cares about the single worst direction β it’s a much more adversarial, worst-case quantity. This distinction matters a lot later.
Small example to make it concrete: if $A$ is a rotation matrix, every direction gets stretched by exactly 1, so $|A|_2 = 1$. If $A$ has one direction where it stretches by 100 and everywhere else it barely does anything, $|A|_2 = 100$, even though most of the matrix “looks small.” Spectral norm doesn’t care about “most” β it cares about the max.
Relevance to ML
1. Lipschitz constants and stability. For a linear layer $y = Wx$, the spectral norm of $W$ is exactly the Lipschitz constant of that layer:
$$|Wx_1 - Wx_2| \leq |W|_2 |x_1 - x_2|$$Stack layers, and (loosely, ignoring nonlinearities) the Lipschitz constant of the whole network is bounded by the product of the spectral norms of each layer. This is the whole reason spectral norm shows up constantly in generalization bounds and adversarial robustness β a network with tightly controlled per-layer spectral norms can’t blow up small input perturbations into huge output changes.
2. Spectral normalization (Miyato et al., 2018). Directly divides each weight matrix by its spectral norm before the forward pass, forcing $|W|_2 = 1$ exactly. This was the trick that made GAN discriminator training actually stable β before this, discriminators would blow up and destabilize the whole adversarial game. Now it’s used well beyond GANs, in places wherever you need Lipschitz-bounded layers (like some flow-based generative models where you need invertibility guarantees).
3. Generalization bounds. A bunch of PAC-Bayes / margin-based generalization bounds for deep nets (Bartlett et al. and follow-ups) have the product of spectral norms across layers sitting right in the bound, sometimes as $\prod_i |W_i|_2$. Big spectral norms β looser bound β intuition that “the network is more sensitive, more likely to overfit / be non-robust.” This is one of the few theoretically-grounded knobs people point to when they say “flatter/more controlled networks generalize better.”
4. Weight clipping alternative in WGANs. Original WGAN clipped weights to enforce a Lipschitz constraint (crudely). WGAN-GP moved to a gradient penalty instead. Spectral normalization is basically the “correct” and much cleaner way to enforce the same Lipschitz constraint that weight clipping was trying to hack together.
5. Adversarial robustness. Since spectral norm literally is the worst-case amplification factor, controlling it is a direct way to bound how much an adversarial perturbation $\delta$ can get amplified as it passes through a layer: $|W\delta| \le |W|_2 |\delta|$. Lower spectral norm β adversarial noise gets damped rather than amplified as it propagates.
How it’s Computed?
Exact spectral norm needs full SVD, which is expensive for big weight matrices. In practice everyone uses power iteration:
- Start with random vector $v$
- Repeat: $v \leftarrow \dfrac{W^T W v}{|W^T W v|}$
- $|W|_2 \approx |Wv|$
Converges fast (few iterations) because it’s just repeatedly applying $W^TW$ and it naturally amplifies the direction of the dominant eigenvalue. This is literally what spectral normalization layers do β one power iteration step per forward pass, updated on the fly, instead of ever computing full SVD.
connecting it back
Nice place this loops back to stuff I already have notes on:
- SVD note β spectral norm is just $\sigma_1$ from that same decomposition
- optimizers note β Hessian’s spectral norm relates to how large a step size you can safely take (curvature bound) β same “worst-case direction” idea as here
- scaling laws / pruning β could be worth checking if spectral norm of layer weights correlates with which examples are “hard”/prunable β probably a stretch but worth a 10-min sanity check sometime