Foundations to Frontier
Tests
E. Deep Learning › E5 Normalization Layers (one page each)

Weight Normalization

Weight normalisation rewrites each weight vector as w = g·v/‖v‖, separating its length g from its direction v, and trains g and v instead of w. Unlike BatchNorm it uses no batch statistics, adds almost no computation and behaves the same in training and inference; it is used in generative models, reinforcement learning and audio networks. This page covers the reparametrisation, its gradients, why the direction's norm grows and damps the effective step, and data-dependent initialisation. In the exercises you gradient-check the reparametrisation and show the direction's norm can only grow under plain gradient steps, then train a deep MLP and find weight normalisation helped a little at a high learning rate, far less than BatchNorm.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Learn a weight’s length and direction separately

Every unit’s weights form a vector with a length and a direction. Weight normalisation stores them separately: one number g for the length, and a vector v whose direction (v divided by its own length) is used. Gradient descent can then change how strongly a unit responds without disturbing which pattern it responds to, and the reverse. It needs no batch of examples, so it works the same everywhere.

Normalisation layers: which values share a mean and variance?
channels →ex 1ex 2ex 3ex 4ex 5ex 6
Click a cell. Highlighted cells (16 values each) are pooled to compute the mean and variance used to normalise it.
per-example mean / sd after normalising0.00/1.00 0.00/1.00 0.00/1.00 0.00/1.00 0.00/1.00 0.00/1.00
per-channel mean / sd after normalising0.63/0.25 0.59/0.76 0.05/1.18 -0.92/0.23 -1.14/0.66 -0.37/1.01 0.45/0.23 0.70/0.81
BatchNorm noise: with batch size 6, a channel's batch mean is off from its population mean by 0.288 on average.
BatchNorm makes every channel have mean 0 and sd 1 across the batch, but each example's own statistics still vary, and its statistics depend on which other examples are in the batch: shrink N to 1 or 2 and watch the noise grow. LayerNorm, InstanceNorm and GroupNorm compute everything within one example, so they work the same at any batch size and at test time; they differ in which channels they pool.

The demo shows the activation normalisations for comparison; weight normalisation acts on the weights instead and has no pooling set.

Why engineers care

Weight normalisation is cheap, deterministic and batch-independent, which suits reinforcement learning (where batches are correlated), generative models such as WaveNet-style vocoders and some GANs, and small-batch or online training where BatchNorm is awkward.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Weight normalisation separates each weight vector into…
  2. 2. Weight normalisation uses batch statistics?
  3. 3. It is popular in…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Reparametrisation: w = g·v/‖v‖. Example: v = (3, 4), g = 10 → w = (6, 8). Any w is reached with v = w, g = ‖w‖ (so the network can start exactly as before).
  • Gradients: with ∇_w the gradient for w and v̂ = v/‖v‖:
    • ∇_g = v̂·∇_w; for v = (3, 4), ∇_w = (1, 1): 1.4.
    • ∇_v = (g/‖v‖)(∇_w − v̂(v̂·∇_w)), which is ∇_w with its component along v removed, then scaled by g/‖v‖.
  • Norm growth: ∇_v ⟂ v, so a step v − η∇_v has length √(‖v‖² + η²‖∇_v‖²) ≥ ‖v‖; a step of size 4 orthogonal to a v of length 3 gives length 5. A longer v means a smaller change in direction per step.
  • Data-dependent initialisation (Salimans and Kingma): on a first batch, set g = 1/std and b = −mean/std of each unit’s pre-activations. For pre-activations 1 and 3: g = 1, b = −2.
📝 Quick check (Level 1)
0/3 answered
  1. 1. w for v = (3, 4), g = 10:
  2. 2. ∇_v is orthogonal to…
  3. 3. Length after an orthogonal step of 4 from length 3:

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Weight normalisation in code

Exercise 1.

  • The gradients for g and v matched finite differences to 10⁻⁸, and ∇_v·v = 0.
  • Over 50 plain gradient steps ‖v‖ grew from 0.93 to 3.47 and never decreased.

Practice.

  • torch.nn.utils.parametrizations.weight_norm(layer) adds the reparametrisation to an existing layer.
  • Use data-dependent initialisation or initialise from the plain weights (v = w, g = ‖w‖).
  • With Adam, the norm growth of v matters less, since Adam rescales steps; with SGD it acts as an automatic decay of the effective learning rate.
  • Combine with mean-only BatchNorm, or use alone where batch statistics are unavailable.
layer = torch.nn.utils.parametrizations.weight_norm(torch.nn.Linear(256, 256))
🐍 Exercise 1: gradients of the reparametrisation
Implement weight normalisation and its gradients, check them against finite differences, and show that plain gradient steps never shorten v.
📝 Quick check (Level 2)
0/3 answered
  1. 1. PyTorch adds weight normalisation via…
  2. 2. Under SGD, v's growth acts as…
  3. 3. Data-dependent initialisation sets g to…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Conditioning. Salimans and Kingma (2016) showed that the gradient for v is the gradient for w projected away from the current direction and scaled by g/‖v‖. This scaling partly corrects for poorly scaled weights, which improves the conditioning of the optimisation, in a way similar to (but weaker than) BatchNorm’s whitening of activations.

Self-stabilisation. Because ‖v‖ grows whenever steps are large, the effective step on the direction, proportional to 1/‖v‖, shrinks automatically. Large learning rates are partly self-corrected, which is related to BatchNorm’s scale invariance (E5-1).

What it does not do. Weight normalisation fixes the scale of weights, not of activations. Activations can still drift in mean and variance through depth unless initialisation is careful, which is why data-dependent initialisation matters and why the gains in exercise 2 were modest.

Relatives. Weight standardisation normalises each weight vector to mean 0 and unit variance; spectral normalisation (E5-7) divides a whole matrix by its largest singular value.

📝 Quick check (Level 3)
0/3 answered
  1. 1. ∇_v equals ∇_w projected away from v and scaled by…
  2. 2. Weight normalisation fixes the scale of…
  3. 3. Spectral normalisation divides a matrix by…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Weight normalisation in a deep MLP

History.

  • T. Salimans and D. Kingma (2016) introduced weight normalisation.
  • It was used in PixelCNN++ (2017), several WaveNet-style vocoders and GAN discriminators.
  • S. Qiao et al. (2019) proposed weight standardisation; T. Miyato et al. (2018) spectral normalisation.

Exercise 2. The 8-layer ReLU MLP of E5-1 on spirals, trained by SGD with momentum for 500 steps, with plain or weight-normalised weights (initialised to the same w). Test accuracy for three seeds:

weights η = 0.03 η = 0.1 η = 0.3
plain 0.998, 1.000, 0.998 0.340, 0.331, 0.320 0.340, 0.326, 0.320
weight-normalised 1.000, 1.000, 1.000 0.501, 0.808, 0.320 0.340, 0.460, 0.320
  • Both trained at η = 0.03.
  • At 0.1 weight normalisation escaped the chance-level plateau in 2 of 3 runs, while the plain network never did; at 0.3 both failed.
  • These runs are near the edge of stability and vary with rounding: in the browser the weight-normalised network gave 1.000, 1.000, 0.778 at η = 0.03 and 0.925, 0.810, 0.320 at η = 0.1. The direction of the comparison is the same.
  • The benefit was modest: BatchNorm in E5-1 trained all seeds at 0.1 and 0.3. Weight normalisation does not control the scale of activations.
🐍 Exercise 2 (research): weight normalisation in a deep MLP
Train a deep MLP with plain and weight-normalised weights at three learning rates and compare.

Weight normalisation in AI, robotics and aerospace

  • Reinforcement learning for control, where correlated batches make BatchNorm problematic.
  • Generative audio and signal models (vocoders) used in speech interfaces.
  • Online adaptation of models one sample at a time, where batch statistics are unavailable.

References

  1. T. Salimans, D. P. Kingma (2016). “Weight normalization: a simple reparameterization to accelerate training of deep neural networks.” Advances in NeurIPS.
  2. T. Salimans, A. Karpathy, X. Chen, D. P. Kingma (2017). “PixelCNN++.” Proc. ICLR.
  3. S. Qiao et al. (2019). “Micro-batch training with batch-channel normalization and weight standardization.” arXiv:1903.10520.