Skip to content

Gradient Clipping for Exploding Gradients Explained

Training recurrent networks has two known problems, vanishing and exploding gradients. The paper studies them analytically and geometrically, then proposes a simple fix for the exploding case: "a gradient norm clipping strategy."

The rule is short. Compute the gradient g. If its norm is at least a threshold, replace it with threshold × g / ‖g‖. The direction is unchanged and the length becomes the threshold. With a gradient of norm 50 and a threshold of 5, the factor is 5/50 = 0.1.

Their picture is a loss surface with steep walls. A step that lands near a wall produces a huge gradient, and following it throws the parameters far from the valley. Because the gradient still points the right way, only the step length needs capping.

How do you pick the threshold? The paper suggests looking at the average gradient norm over many updates. In its experiments, training "is not very sensitive to this hyper-parameter" and works "even for rather small thresholds."

On polyphonic music prediction, the Nottingham test negative log likelihood per time step was 3.80 with plain SGD and 3.48 with clipping, lower being better.

Pascanu, Mikolov, and Bengio, ICML 2013, §3.2 (Algorithm 1) and §4 (Table 1)