Skip to content

Gradient Clipping

Technique in training: if the gradient exceeds a threshold, it is reduced to an acceptable value. Protects against 'exploding gradients'.

Why

In recurrent networks and transformers, gradients can suddenly become very large, causing parameters to update to unreasonable values after the update. The model breaks: responses become garbage, and training diverges.

Types

  • by norm — if the length of the gradient vector exceeds the threshold, the entire vector is scaled;
  • by value — each component is limited to a range.

In practice, clipping by norm is more commonly used: it preserves the direction of the gradient, changing only its length.

See also

← All terms