§10.7–10.9.2Long-Term Dependencies · Echo State Networks · Leaky Units

Part II DL pp. 401–407 · ~6 min read

  • long-term dependencies
  • echo state network (esn)
  • reservoir computing
  • spectral radius
  • leaky unit
  • skip connections through time

§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)

h(t)=Wh(t1)=Wth(0),W=QΛQ    h(t)=QΛtQh(0)h^{(t)} = W h^{(t-1)} = W^{t} h^{(0)}, \qquad W = Q\Lambda Q^{\top} \;\Rightarrow\; h^{(t)} = Q\,\Lambda^{t}\,Q^{\top} h^{(0)}
Wth(0)W^{t} h^{(0)}with no nonlinearity or input, running the recurrence t times is just multiplying the initial state by W repeatedlythe power method
W=QΛQW = Q\Lambda Q^{\top}eigendecomposition — orthogonal Q of eigenvectors, diagonal Λ of eigenvaluesfactorization
Λt\Lambda^{t}each eigenvalue λ is raised to the power t: |λ|<1 decays to 0 (vanish), |λ|>1 blows up (explode)the exponential
Qh(0)Q^{\top} h^{(0)}any part of the initial state not aligned with the largest eigenvector is eventually discardedprojection

The magnitude after tt steps scales as the spectral radius raised to the power tt. Drag ρ\rho 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:

Fig 10.15 (interactive) — repeated multiplication by W. Magnitude ≈ ρᵗ where ρ is the spectral radius (largest |eigenvalue|). ρ<1 vanishes, ρ≈1 holds, ρ>1 explodes; the spiral shows a vector Wᵗv₀ winding in or out.
initial magnitude‖·‖t = 200
Wᵗ v₀

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 ww by itself gives wtw^t, which vanishes or explodes. But a non-recurrent net with a different weight w(t)w^{(t)} each step can be scaled (variance 1/n\propto 1/n) to keep the product well-behaved (Sussillo 2014) — the difficulty is special to sharing one WW 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 (xhx \to h) and recurrent weights (hhh \to h) are the hardest parameters to learn. Echo state networks (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 .

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 h(t)h^{(t)} — 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 (largest λ|\lambda|) governs whether a perturbation grows or shrinks: after nn back-prop steps a deviation of size δ\delta becomes δλn\delta|\lambda|^n — explode if λ>1|\lambda| > 1, shrink if λ<1|\lambda| < 1 (rewind the widget above to see it). A contractive map (λ<1|\lambda| < 1) 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 (tt+1t \to t+1), a connection with delay dd spans dd steps — so gradients decay over τ/d\tau/d rather than τ\tau:

Fig — skip connections through time. Alongside the length-1 recurrent edges, delay-d edges (here d=2, dashed) let gradients traverse fewer hops from distant past to present: decay over τ/d instead of τ.
h1h2h3h4h5delay d = 2length-1 recurrent edges

§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 μ(t)αμ(t1)+(1α)v(t)\mu^{(t)} \leftarrow \alpha\,\mu^{(t-1)} + (1-\alpha)\,v^{(t)} — the coefficient α\alpha is exactly such a self-loop. A leaky unit is a hidden unit that behaves this way. Slide α\alpha to trade fast forgetting for long memory:

Fig (interactive) — a leaky unit μ⁽ᵗ⁾=α·μ⁽ᵗ⁻¹⁾+(1−α)·v⁽ᵗ⁾ responding to an input pulse. α→1 remembers the pulse long after it ends (memory ≈ 1/(1−α) steps); α→0 tracks the input and forgets fast.
input v⁽ᵗ⁾ = 110t = 30μ⁽ᵗ⁾

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 dd ties a unit to a value exactly dd steps back (an integer), the linear self-loop lets the same effect be adapted smoothly by tuning the real-valued α\alpha. 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?

6 questions