This page is a self-test. Read each problem, try it on paper, THEN open the collapsible solution. The exercises climb from recognising the vanishing-gradient pattern to designing fixes.
Before anything, let us define every symbol used on this page, in plain words, so you never meet a piece of notation cold:
Figure s01 below plots the tanh curve and its slope — Exercise 1.2 refers to it directly.
When every step multiplies the gradient by the same number γ, doing it (T−t) times means raising γ to that power — that is just what "multiply by γ, 20 times over" means.
0.820≈0.0115
The gradient shrinks to about 1.15% of its size — this is vanishing (each step multiplies by a number below 1, so 20 of them push toward zero).
Recall Solution 1.2
Look at figure s01 (embedded near the top of this page, titled "s01 Activation factor: tanh and its slope"). The slope is largest where the tanh curve is steepest — at z=0, where tanh(0)=0 so tanh′(0)=1−0=1. That is the maximum, value =1.
As ∣z∣→∞, tanh(z)→±1, so tanh2(z)→1 and tanh′(z)→1−1=0. The tanh saturates (goes flat) and its slope dies to 0. This is why large pre-activations are dangerous: the activation factor collapses.
Recall Solution 1.3
(a) 0.5<1⇒vanishing (weight factor shrinks each step).
(b) 2.0>1⇒exploding (weight factor grows each step). See Exploding Gradients.
(c) Saturation makes tanh′→0⇒vanishing (activation factor shrinks).
(d) Weight factor =1 and slope =1⇒ product stays near 1 ⇒neither (the borderline "healthy" case).
With a linear recurrence the local derivative ∂hk/∂hk−1 is exactly 0.95 every step (the coefficient in front of hk−1), so chaining 40 of them gives 0.9540.
∂h0∂h40=0.9540≈0.1285
The update scale is 0.01×0.1285≈1.28×10−3 — small but not dead yet. γ=0.95 decays slowly; the problem bites harder for longer sequences or smaller γ.
Recall Solution 2.2
Why group first? Each single step contributes the producttanh′(zk)⋅Whh=0.2×0.95. So one step's multiplier is 0.2×0.95=0.19. Because multiplication is associative and every step has the same 0.19, the whole (T−t)-fold product is just 0.19 raised to the power of the gap — we are allowed to collapse the two same-valued factors into one number before exponentiating, since (ab)n=anbn and here a,b repeat identically every step.
(0.2×0.95)40=0.1940≈3.9×10−30
Numerically vanished. Note 0.2 came from tanh's slope and 0.95 from the weight norm — separate factors that just happen to multiply, exactly as the L1 trap warned.
Recall Solution 2.3
LSTM cell path (see LSTM Architecture): 0.99100≈0.366 — about 37% survives. This is the gradient highway: the additive cell update means the multiplier is the learned gate, kept near 1.
Plain RNN: 0.9100≈2.66×10−5 — essentially gone.
The LSTM preserves roughly 13,000× more gradient over 100 steps.
Dividing two powers of the same base subtracts exponents, so the unknown a (a possible constant) cancels: γ10γ20=γ10=0.1070.0115≈0.1075.
So γ=0.10751/10≈0.800. Check: 0.810≈0.107 ✓ and 0.820≈0.0115 ✓. The measured base is γ≈0.8.
Recall Solution 3.2
We need 10−2≤∥Whh∥30≤102.
Why the 30th root is legal: the function u↦u1/30 is strictly increasing for u>0, so applying it to all three sides of the inequality preserves the order (it never flips ≤). That is why we may root through:
10−2/30≤∥Whh∥≤102/300.858≤∥Whh∥≤1.079
So the largest spectral norm that still avoids explosion at 30 steps is ≈1.079, and the smallest that avoids vanishing is ≈0.858. The healthy window is the narrow band [0.858,1.079] around 1. Push above 1.079 and you enter Exploding Gradients; drop below 0.858 and you vanish. Real saturation (tanh′<1) shifts the whole band upward (you need a bigger ∥Whh∥ just to break even), squeezing plain RNNs from both sides — which is why they are stuck.
Recall Solution 3.3
With ReLU′=1 the activation factor is exactly 1, so the whole product is ∥Whh∥25:
1.325≈705.6
The gradient exploded by a factor of ~700. Removing tanh's damping did not fix credit assignment — it just handed control entirely to ∥Whh∥, and 1.3>1 blows up. See Activation Functions and Gradient Clipping.
Recall Solution 3.4
Only the magnitude of an eigenvalue drives vanishing/exploding, but the sign and phase shape the path:
Negative eigenvalue (e.g. −0.9): each step also flips the sign, so the gradient's sign oscillates+,−,+,− while its magnitude still decays like 0.9n. The envelope vanishes, but non-monotonically.
Complex eigenvalues (they come in conjugate pairs for real Whh): the gradient rotates in the plane spanned by that pair. The norm follows ∣λ∣n (so still vanishes if ∣λ∣<1, explodes if ∣λ∣>1), but the components spiral — the norm can rise and fall along the way rather than dropping smoothly.
Takeaway: the ∥Whh∥T−t curve is an envelope; the true per-component gradient can wobble or spiral inside it. This is why measured gradient norms are often bumpy, not clean exponentials.
We need 10−2≤∥Whh∥50≤102. Why we may root through:u↦u1/50 is strictly increasing on u>0, so it preserves the direction of both ≤ signs. Take 50th roots of all sides:
10−2/50≤∥Whh∥≤102/500.912≤∥Whh∥≤1.096
An extremely narrow band around 1. Real training can't hold the spectral norm in a ±9% window for 50 steps — hence the need for gated highways where the effective multiplier (ft≈1) is learned rather than luck.
Recall Solution 4.2
0.98200≈0.0176
About 1.8% survives over 200 steps — usable for learning. The forget gate (LSTM Architecture) is doing the heavy lifting: it keeps the per-step multiplier near 1 additively. Gradient Clipping never activates on the vanishing side (clipping only caps large norms) — it is insurance against the occasional exploding spike, not a cure for decay. Two different jobs, two different tools.
Recall Solution 4.3
Differentiate: ∂ht−1∂ht=I+diag(tanh′(zt))Whh, where I is the identity matrix (leaves any vector unchanged).
The identity term is the key: even if the tanh-weight part shrinks to 0, the derivative floors at I, so the product ∏(I+⋯) never collapses to zero. This is exactly the LSTM's additive cell path (∂Ct/∂Ct−1=ft with ft≈1) and the idea behind Residual Connections and Attention Mechanisms — give gradients an un-multiplied shortcut back through time.
(a) Plain RNN: 0.8560≈5.8×10−5. LSTM: 0.99560≈0.741.
(b) Threshold is 10−3. Plain RNN gives 5.8×10−5<10−3 ✗ — it cannot learn the cat→was agreement; the singular subject signal has vanished. LSTM gives 0.741>10−3 ✓ — the highway keeps ~74% of the signal, so the agreement is learnable. This is the parent note's motivating example made quantitative.
Recall Solution 5.2
(a) S(10)S(30)=r20=0.600.216=0.36, so r=0.361/20≈0.9500. Then a=S(10)/r10=0.60/0.9510=0.60/0.5987≈1.002.
(b) Solve arg<10−2. Taking logs is legal because ln is strictly increasing (preserves <), and dividing by lnrflips the inequality since lnr<0: g>ln0.95ln(9.98×10−3)≈−0.0513−4.610≈89.9. So beyond a gap of about 90 steps the gradient drops below 10−2.
Recall Solution 5.3
What axes does BatchNorm act on? In an RNN the hidden state at step t for one example is a vector ht. During training we process a batch of N sequences at once, so at each time step we hold a tensor of shape (batch N, features H). BatchNorm computes, for each feature channel, the mean and variance across the N examples and rescales that channel to zero-mean/unit-variance. Its averaging axis is the batch axis (N different sequences), one normalisation per time step.
Steel-man (why it seems plausible): in feedforward nets this keeps each pre-activation z near 0, so tanh′(z) stays near its max of 1 — it genuinely fights the activation-factor shrinkage.
Refutation — the dimension mismatch: the vanishing product ∏kdiag(tanh′(zk))Whh accumulates along the time axis (k=t+1,…,T) within a single sequence. BatchNorm never touches that axis — it only averages across sequences at a fixed time step. So it operates on the batch dimension while the decay lives on the time dimension: normalising one sequence-vs-another does nothing to the chain of multiplications running down a single sequence's timeline, and it does nothing to ∥Whh∥ (a weight, not an activation). It can slightly reduce saturation, but the temporal weight-factor decay is fully intact. The real fix is architectural — gates (LSTM Architecture, GRU Architecture), residual shortcuts (Residual Connections), or Attention Mechanisms.