TL;DR
Weight normalization changes how a neuron's weights are stored. Instead of learning the weight vector directly, the network learns a direction and a scalar length , and uses . Training then adjusts the size of the weights and their direction separately, and the gradient steps on the direction stay well scaled. The method adds only one extra number per neuron.
Builds on: Vector Norm, Chain Rule, Gradient · Leads to: the 2016 weight normalization paper
Where it's used
Training small and medium convolutional networks. Salimans and Kingma (2016) reported faster convergence on image classification and generative models, such as deep convolutional networks trained on CIFAR-10, with the method applied to each layer's weights. It is most useful in research code where batch statistics are awkward.
Reinforcement learning and generative models. Because weight normalization does not use statistics from a batch, it works when batches are small, when examples in a batch are correlated, or when the batch is not the right unit, as in some reinforcement learning, generative and sequential models. Those settings are where Batch Normalization is least reliable.
Built into deep-learning frameworks. Libraries such as PyTorch provide a weight-norm wrapper that applies the reparameterization to a layer's weight, so a practitioner can add it with one line. It is a tool for changing how a layer is parametrised, not a separate block in the network.
How it works
Take a single neuron with a 2-number weight vector and no bias. Its output for an input is . Start with the learned direction and the learned length .
- Compute the length of : .
- Divide by its length to get a unit direction: . Check: .
- Multiply the unit direction by the learned length: .
- Check the length of the actual weight: . The weight's length is exactly , whatever was.
- Use the weight as usual. For input the output is .
- During training, the gradient of the loss is taken with respect to and , not . Each gradient step moves to change the length, and moves to change the direction. Because a step on changes its direction without changing its length much, the length of the neuron's weights is controlled by alone.
The picture is simple: one knob sets how big the weights are, and the other sets which way they point.
flowchart LR
G[Learned length g] --> W[Weight w = g times v over norm v]
V[Learned direction v] --> W
W --> O[Output w dot x]
O --> L[Loss]
L -->|gradient| G
L -->|gradient| V
The diagram shows that the loss feeds gradients into both learned quantities, and the weight is rebuilt from them at every forward pass.
The math
Write for the direction parameter, for the length parameter and for the effective weight vector of one neuron.
Step 1 in symbols: the reparameterization
The effective weight is
where is the Euclidean length defined in Vector Norm. The length of is , as the walkthrough checked.
Step 2 in symbols: the direction is a unit vector
Let . Then , and . The scale of cancels: if you multiply by any positive number , does not change. This is why the effective weights are unchanged by a rescaling of .
Step 3 in symbols: the gradients
Let be the loss, and write for the gradient with respect to the effective weights, computed as usual by Backpropagation, which applies the Chain Rule. Then the gradient for the length is the dot product of and , divided by the length of :
and the gradient for the direction parameter is
The second expression subtracts from its component along . Thus the gradient on is perpendicular to . A small step along it changes the direction but barely changes the length of , to first order. This is the mechanism behind the claim in the walkthrough.
Step 4 in symbols: the training step
Gradient descent (see Gradient Descent, or its stochastic version on minibatches) updates both parameters with the same learning rate :
Each step changes by a scalar and changes in a direction orthogonal to itself.
Worked examples
Take and .
- The length of is .
- The scale factor is .
- The weight is .
- The length of the weight is , which equals .
- Interpret. The direction of is the direction of , and its length was set by rather than by the size of .
Use the same and . Suppose the loss gradient with respect to the effective weight is . Find the gradients with respect to and , then take one step with .
- The unit direction is .
- The gradient for is .
- The component of along is . Subtracting from gives .
- Multiply by : the gradient for is .
- Check orthogonality: . The gradient is perpendicular to .
- Update: . And .
- The new squared length of is , so the length is . The squared length grew by , a tiny change.
- Interpret. The step turned slightly and shortened the length . The size of barely changed, so the next forward pass depends on far more than on 's length.
A unit has three inputs. Its direction is and its length is . Take an input .
- The length of is .
- The weight is .
- The output is .
- Suppose a later update makes ten times larger, , and leaves unchanged. The length of is now , and .
- The weight, and so the output , is unchanged.
- Interpret. Growing the raw parameters did not change what the unit computes, so the optimizer cannot inflate the weights simply by taking large steps.
Try it: A unit has and , and the same input . What is the output, as a number?
Answer: The length of is , so . The output is . Doubling from to doubled the output from to , because the output is linear in .
Common mistakes and tradeoffs
Mistake: "Weight normalization normalises the activations." It is tempting to think it works like Batch Normalization, which rescales the outputs of a layer. In fact it rescales the weights, not the activations. It does not compute any statistics over the data, so it does not fix shifts in the activation distribution in the same way.
Mistake: "It removes the need for a learning rate." It is tempting to think the length and direction parameters adjust themselves. In fact the learning rate still matters, and a poor choice can still destabilise training.
Mistake: "The stored parameters are just the old weights under a new name." It is tempting to think the parameters are just a new name for the old ones. In fact the stored parameters are and , and the gradients flow through the division by , which is why the update to is perpendicular to .
When to use it. Use weight normalization when batch statistics are unavailable or unreliable, such as with very small batches, or when you want a cheap change that does not depend on the batch at all. It adds only one parameter per neuron.
When not to use it. Avoid relying on it as the only normalisation in a network whose activations drift a lot, because it does not control activation scale. Layer-style normalisation or batch normalisation may handle that better.
Alternatives. Batch Normalization normalises activations using batch statistics, and is the usual choice when batches are large. Layer normalisation normalises over features of one example. Both act on activations, so they address a different issue from weight normalization.
History
By the mid-2010s, batch normalization had shown that normalising the signals inside a deep network could speed up training, but it depended on batch statistics, which made it awkward for small batches and some sequential models. In 2016 Tim Salimans and Diederik Kingma asked whether the weights themselves could be normalised instead. Their answer was to reparameterise each weight vector as a length and a direction, and to show that the gradients behave well in that form.
The paper showed faster training on several image and generative benchmarks, and it was adopted in research codebases, where it was simple to add. It did not replace batch normalization in most large-scale vision work, but it remains a standard example of reparameterising a model to make optimisation easier.
Recap
- A weight vector is rebuilt as a learned length times the unit vector in the learned direction .
- The length of the effective weight is exactly , and rescaling leaves the weight unchanged.
- The gradient on is perpendicular to , so direction changes do not inflate the length.
- The method uses no batch statistics, which is its main practical advantage.
- It normalises weights, not activations, so it is a different tool from batch normalization.
What to read next: Batch Normalization shows the activation-based alternative, and Reparameterization Trick shows another use of rewriting a parameter to make gradients usable.
Check yourself
QuestionRecall: what are the two learned quantities in weight normalization, and what does each control?Show answer
The learned quantities are the direction parameter and the scalar length . The effective weight is , so controls which way the weight points and controls its length.
QuestionComputation: a neuron has and . What is its effective weight , and what is its length?Show answer
The length of is . The weight is . Its length is , which equals .
QuestionWhy: why is the gradient with respect to perpendicular to , and what does that mean for training?Show answer
The gradient removes from its component along , so what remains is orthogonal to . A small step perpendicular to changes its direction but adds only a second-order change to its length. So the size of the weight is controlled by , and gradient steps on mostly rotate it.
QuestionApplied: you train a small recurrent model whose batches contain only 4 correlated sequences, and batch normalization gives noisy results. Would weight normalization be a sensible replacement, and what is one thing it would not fix?Show answer
It is a sensible choice, because it does not use batch statistics, so the batch size and the correlation between sequences do not affect it. It would not fix activations that drift in scale or shift across time, because it normalises the weights, not the activations. A layer-level normalisation of the activations would be needed for that.