§10.7 The challenge of long-term dependencies
We met this obstacle in §8.2.5; now we see it in its natural home. The problem: gradients propagated over many time steps tend to either vanish (almost always) or explode (rarely, but catastrophically). An RNN composes the same function once per step, and that composition is a product of many Jacobians — so even a perfectly stable RNN gives a long-term interaction exponentially smaller weight than a short-term one. Composing many linear-tanh layers produces a wildly nonlinear map (fig 10.15) whose derivatives are mostly tiny, with rare large spikes.
Strip away the nonlinearity and the input, and the recurrence becomes pure repeated matrix multiplication — the power method:
Recurrence as the power method (eqs 10.36–10.39)
| with no nonlinearity or input, running the recurrence t times is just multiplying the initial state by W repeatedly | the power method | |
| eigendecomposition — orthogonal Q of eigenvectors, diagonal Λ of eigenvalues | factorization | |
| each eigenvalue λ is raised to the power t: |λ|<1 decays to 0 (vanish), |λ|>1 blows up (explode) | the exponential | |
| any part of the initial state not aligned with the largest eigenvector is eventually discarded | projection |
The magnitude after steps scales as the spectral radius raised to the power . Drag across 1 to see the three regimes — decay, edge of stability, explosion — in both the magnitude curve and a vector spiralling in or out under repeated multiplication:
After 20 steps the magnitude is ≈ ρ20 = 0.01 × the initial. ρ < 1: every component not aligned with the top eigenvector decays to zero — gradients VANISH, and short-term signals drown out long-term ones.
Contrast the scalar case: multiplying a weight by itself gives , which vanishes or explodes. But a non-recurrent net with a different weight each step can be scaled (variance ) to keep the product well-behaved (Sussillo 2014) — the difficulty is special to sharing one across time.
The memory–gradient dilemma
Couldn’t we just keep the parameters where gradients neither vanish nor explode? Unfortunately, to store a memory robustly — so small perturbations don’t erase it — the RNN must enter the region where gradients vanish. So whenever the model is actually able to represent a long-term dependency, the gradient of that long-term interaction is exponentially smaller than the short-term ones. It is not impossible to learn, just very slow: in practice, plain-RNN SGD success drops toward zero for dependencies spanning only 10–20 steps. The rest of the chapter is a catalog of ways around this.
§10.8 Echo state networks
The input weights () and recurrent weights () are the hardest parameters to learn. Echo state networks echo state network (esn) A recurrent network whose input and recurrent weights are fixed (not learned) so the hidden units form a rich reservoir of temporal features; only the output weights are trained, often via a convex criterion. defined in ch. 10 — open in glossary (and the spiking-neuron liquid state machines) sidestep the problem entirely: fix those weights so the hidden units form a rich reservoir of temporal features, and learn only the output weights. Because the readout is typically a linear regression from the state, its training criterion is convex and solvable reliably. This family is called reservoir computing reservoir computing The umbrella term (covering echo state networks and liquid state machines) for models that map a sequence into a fixed-length recurrent state — a fixed ‘reservoir’ of features — on which a simple linear predictor is trained. defined in ch. 10 — open in glossary .
A reservoir is a kernel machine for sequences
Think of the reservoir as mapping an arbitrary-length input history into a fixed-length vector — the state — on which a simple linear predictor is trained. That is exactly the shape of a kernel machine: a fixed nonlinear feature map followed by a linear, convex readout.
How do you set the fixed weights? View the recurrent net as a dynamical system and place it near the edge of stability — make the eigenvalues of the state-to-state Jacobian near 1. Its spectral radius spectral radius The maximum absolute value among a matrix’s eigenvalues. For an RNN’s state-to-state Jacobian it governs whether small perturbations (and gradients) grow or shrink over time; reservoir methods tune it near the edge of stability. defined in ch. 10 — open in glossary (largest ) governs whether a perturbation grows or shrinks: after back-prop steps a deviation of size becomes — explode if , shrink if (rewind the widget above to see it). A contractive map () necessarily forgets the past at finite precision.
Crucially, a saturating tanh bounds the forward dynamics — the derivative approaches 0 on many steps and prevents explosion — so modern ESNs deliberately use a spectral radius much larger than 1 (around 3). The same trick even helps initialize a fully trainable RNN: start with spectral radius ≈ 1.2 plus the sparse initialization of §8.4, then train the recurrent weights normally.
§10.9 Leaky units and a spectrum of time scales
A different tack: build a model that operates at multiple time scales at once — some parts fine-grained (small details), others coarse (carrying information from the distant past efficiently). Three strategies appear: adding skip connections across time, using leaky units, and removing fine-scale connections (the last covered next).
§10.9.1 Skip connections through time
Add direct edges from the distant past to the present. Where an ordinary recurrent connection spans one step (), a connection with delay spans steps — so gradients decay over rather than :
§10.9.2 Leaky units
Another way to get a product of derivatives near 1: a unit with a linear self-connection whose weight is near 1. Accumulate a running average — the coefficient is exactly such a self-loop. A leaky unit leaky unit A hidden unit with a linear self-connection µ^(t) ← αµ^(t-1) + (1-α)v^(t) acting as a running average. α near 1 remembers the distant past; α near 0 forgets quickly — a smooth, adaptable way to hold information over time. defined in ch. 10 — open in glossary is a hidden unit that behaves this way. Slide to trade fast forgetting for long memory:
Effective memory ≈ 1/(1−α) ≈ 3.3 steps. Moderate α: a smooth running average — it charges up during the pulse and decays gradually after.
Where a skip connection with delay ties a unit to a value exactly steps back (an integer), the linear self-loop lets the same effect be adapted smoothly by tuning the real-valued . The time constants can be fixed (sampled once at initialization) or made free parameters and learned; leaky units at different time scales help capture long-term dependencies.
Next: forcing units onto coarse time scales, and the architecture that finally tames long-term dependencies — removing connections, and the LSTM & gated RNNs.
Check yourself — long-term dependencies, echo state networks, leaky units
1.Why is learning long-term dependencies in RNNs fundamentally hard?
2.Treating the recurrence as h⁽ᵗ⁾ = W·h⁽ᵗ⁻¹⁾ (no nonlinearity, no input) and using W = QΛQᵀ, what happens over t steps?
3.Why can't we just keep the RNN parameters in a region where gradients neither vanish nor explode?
4.What is the core idea of echo state networks / reservoir computing?
5.How do echo state networks set the recurrent weights, and why can they use a spectral radius as large as 3?
6.In the LeakyUnitLab, μ⁽ᵗ⁾ = α·μ⁽ᵗ⁻¹⁾ + (1−α)·v⁽ᵗ⁾. What does α control, and how do skip connections through time compare?