Gradient Norm Clipping and Update Bounds

Scale a large gradient to a prescribed norm and distinguish whole-batch clipping from clipping individual examples.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Norm clipping keeps direction when it changes magnitude
  2. Timing of the clipping changes the statistic

Norm clipping keeps direction when it changes magnitude

For gradient \(g\) and positive threshold \(C\), use \(g\min(1,C/\|g\|_2)\) when \(g\ne0\). A vector \((6,8)\) has norm ten. At threshold five it becomes \((3,4)\). This bounds the supplied gradient’s norm. The optimizer can still add momentum, decay or other transformations, so the final parameter displacement need not equal a simple scaled version of that norm.

Timing of the clipping changes the statistic

Clipping individual gradients before averaging bounds each observation’s contribution. Clipping their average can hide large opposing terms that cancel. The choices give different training behavior and different sensitivity bounds. Mini-batch gradients describe the ordinary averaging step. Differential privacy uses per-example clipping together with calibrated noise and accounting.[1]

References

  1. Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning ↩