Spectral Normalisation by Power Iteration

medium
Unit 9 · Backprop & Regularization0/3 to milestone

A weight matrix's spectral norm (its largest singular value) bounds how much the layer can stretch its input, so it controls the network's Lipschitz constant. Spectral normalisation (Miyato et al., 2018) divides each weight by it, which stabilises GAN training.

Computing an SVD every step is too slow, so it's estimated with power iteration: repeat v = normalise(Wᵀu), u = normalise(W v), then σ ≈ uᵀWv.

Implement:

  • power_iteration(W, u0, iters=50): return (sigma, u, v)
  • spectral_normalize(W, u0, iters=50): W / sigma
  • lipschitz_bound(weights, u0s, iters=50): the product of the spectral norms of a list of layer weights (an upper bound on an MLP's Lipschitz constant with 1-Lipschitz activations like ReLU)
#regularization#gans#linear-algebra2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Spectral Normalisation by Power Iteration · TechGradify