For a vanilla RNN with , show that , where is the largest singular value. What does this say for and over steps? How does gradient-norm clipping help, for example when the gradient norm is and the threshold is ?
Sequence models and transformers, Recurrent networks
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can bound a product of Jacobians and tie it to vanishing and exploding gradients and to clipping.
Key idea
, with norm at most because . A product of such terms has norm at most .
Steps
- By the chain rule, .
- Each diagonal matrix has entries in , so its spectral norm is at most . Hence .
- Submultiplicativity of the norm gives .
- If : , so the gradient vanishes. This bound is a guarantee.
- If : . This is only an upper bound, so the gradient can explode, but is not forced to. Explosion needs a large spectral radius and active tanh units.
- Clipping: if , replace by . With and the gradient is multiplied by . The direction is kept and only the step size is limited, so one huge gradient cannot throw the weights far away.
- Clipping cures explosion but not vanishing, which needs gated cells such as an LSTM or GRU.
Common mistakes
- Saying always causes exploding gradients; the bound is an upper limit only.
- Clipping each gradient entry separately versus the norm: norm clipping preserves direction.
- Thinking clipping fixes vanishing gradients.
How long your answer should be
Half a page; 5 minutes.
Last checked on 4 December 2026.
Read this
Previous in Sequence models and transformers: LoRA computes , where is initialised to zero and is random. How do you show that at initialisation the model equals the pre-trained one, what are the gradients and at the start, and what is the factor for?
Next in Sequence models and transformers: Let be attention weights over scores . Derive the Jacobian and the backward rule where . For and , compute , and again for the peaky . What does this say about saturated attention?