3.5.3 · D5Sequence Models
Question bank — Vanishing gradients in RNNs
This is a reasoning gym for Vanishing gradients in RNNs. Each item below is a trap that a fast reader falls into. Cover the answer with your hand, commit to a position out loud, then reveal. If your reason doesn't match the reason given, you had the right answer for the wrong cause — which is the trap.
Before you start, three plain-words reminders so nothing below uses a symbol you haven't been handed:
- Spectral norm — the largest stretch factor the weight matrix can apply to any vector. Think "the worst-case zoom the matrix does." When it is below , repeatedly applying the matrix shrinks vectors.
- tanh derivative — how steep the tanh curve is at input . It is at the centre () and slides toward as grows ("saturation").
- Gradient path — the chain of multiplications the loss signal passes through as it travels backward from the last time step to an early one (see Backpropagation Through Time).
True or false — justify
Long sequences are the only cause of vanishing gradients.
False — sequence length only sets how many factors multiply; the per-step factors ( and ) decide whether each multiplication shrinks. A short sequence with tiny factors still vanishes.
If exactly, gradients are guaranteed to be stable.
False — the bound only stops weight-driven decay; the factors still multiply on top and drag the product toward zero, so gradients can still vanish.
Vanishing gradients mean the network's forward predictions are also tiny.
False — the forward pass and backward pass are separate; hidden states can be perfectly healthy while the backward gradient signal to early steps has decayed to near zero.
Using tanh guarantees gradients vanish.
False — tanh only contributes a shrinking factor (); if were large enough it could still explode. tanh biases toward shrinking but does not guarantee it alone.
The vanishing gradient bound is an equality.
False — it is an upper bound (from and ); the true magnitude is usually smaller because the tanh factors shrink it further.
A learned forget gate near in an LSTM keeps the cell-state gradient path near .
True — the cell-state Jacobian is additive-gated, so passes the gradient through almost unchanged, forming the "gradient highway."
Exploding and vanishing gradients are the same phenomenon with a sign flip.
False — they are the same mechanism (repeated multiplication) with opposite outcomes: vanishing when the per-step factor , exploding when . See Exploding Gradients.
Vanishing gradients can be detected by watching the loss value alone.
False — the loss may plateau for many reasons; the telltale sign is that gradients w.r.t. early-time parameters are orders of magnitude smaller than those w.r.t. recent-time parameters.
Spot the error
"tanh saturation reduces , so the weight norm shrinks over training."
Error: saturation shrinks the separate factor, not the weight matrix. is a fixed property of the weights and is untouched by which region of tanh you sit in.
"Since , the product of Jacobians can never exceed , so gradients can never explode with tanh."
Error: the tanh factor caps the tanh contribution, but itself grows without bound when , so tanh RNNs can still explode.
"Switching to ReLU fixes vanishing because ."
Error: ReLU only removes the tanh damping factor; whether gradients vanish or explode now depends entirely on . See the mistake note in Vanishing gradients in RNNs and consider Gradient Clipping.
"Use a learning rate of to cancel a gradient."
Error: different time steps decay at different rates, so one giant learning rate that rescues early steps blows up the recent steps. Adaptive optimizers or architecture fixes are needed instead.
"BatchNorm normalizes activations, so it fixes vanishing gradients in RNNs."
Error: BatchNorm normalizes across the batch dimension; vanishing happens across the time dimension within one sequence, which BatchNorm never touches.
"The gradient is a single number, so we can just clip it."
Error: it is a matrix (a Jacobian), and clipping is applied to the assembled gradient's norm, not to this intermediate — clipping fixes explosion, not vanishing.
Why questions
Why do we multiply Jacobians rather than add them when going back in time?
Because each hidden state depends on the previous one through function composition, and the chain rule turns composition into a product of local derivatives.
Why does a per-step factor below cause exponential (not linear) decay?
Multiplying by the same sub-one factor times gives ; repeated multiplication compounds, which is exponential in the number of steps.
Why does BPTT make the vanishing problem worse for distant dependencies specifically?
The exponent is exactly the time gap, so the further apart the cause and effect, the more shrinking factors multiply — near dependencies barely decay, far ones vanish.
Why can an LSTM escape the exponential trap that a plain RNN cannot?
Its cell-state gradient path is additive and gated () rather than a forced product through squashing nonlinearities, so a learned keeps the path near .
Why do GRUs also help despite having fewer gates than LSTMs?
Their update gate similarly creates an additive skip for the hidden state, giving a near-identity gradient path when the gate says "keep old state."
Why do residual connections and attention address the same underlying issue in other architectures?
Both create short gradient paths (an identity skip, or direct attention weights) so the signal need not traverse a long product of shrinking Jacobians.
Why does saturation () and a small spectral norm push in the same direction yet count as two causes?
Both are factors in the product so both shrink the gradient, but they live in different multiplicands ( vs ) and can be changed independently.
Edge cases
What happens to the gradient path when the time gap (loss at the same step)?
There is no product at all — is the identity, so there's nothing to decay; vanishing needs at least one intervening step.
What if is exactly but all inputs are near zero (tanh at its centre, )?
Both factors are , so the gradient neither vanishes nor explodes — the rare stable "sweet spot" that identity/orthogonal initialization deliberately targets.
What if the forget gate in an LSTM learns a value near ?
Then the cell-state path multiplies by , deliberately erasing old information and its gradient — vanishing here is a feature, letting the model forget irrelevant history.
What happens with an extremely long sequence but a per-step factor of exactly ?
The gradient stays at magnitude no matter how long the sequence, showing that length alone is harmless — it is the factor's size, not the count, that decides the fate.
What is the behaviour when but tanh is deeply saturated so ?
The two factors fight; if the product per step (e.g. ) is below the gradient still vanishes — saturation can rescue stability by damping an otherwise-exploding weight.
Recall Self-test: name the two independent factors
The two per-step shrinking factors are the ==spectral norm and the == activation-derivative diagonal.