Vanishing Gradients › The Vanishing vs Exploding Tradeoff
Language AI HandbookAll chapters Vanishing Gradients › The Vanishing vs Exploding TradeoffOne section · Sections in this chapter10 / 18 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The vanishing and exploding problems define the two sides of a knife-edge. When the spectral radius is far below 1, gradients vanish and long-range learning fails. When it is far above 1, gradients explode and training becomes numerically unstable. The stable regime is a narrow band around spectral radius 1, but even within this band, the tanh nonlinearity prevents perfect gradient preservation across long sequences because for .
This creates a fundamental architectural constraint: vanilla RNNs have no mechanism to maintain gradient magnitude over long distances. The recurrent multiplication is the same every step, driven by the same , and there is no way to independently control gradient flow while also encoding sequence semantics.
spectral_radii = np.linspace(0.1, 1.5, 100)
T_fixed = 50
hidden_size_small = 16
norm_after_T = []
for rho in spectral_radii:
norms = compute_gradient_norms(
T_fixed, hidden_size_small, rho, activation="tanh", seed=7
)
norm_after_T.append(norms[-1])
norm_after_T = np.array(norm_after_T)
The plot makes the tradeoff vivid. Below spectral radius 1, gradient norms collapse toward zero over 50 steps. Above spectral radius 1, they explode. The inflection point near 1 appears to offer a solution, but even there, the tanh nonlinearity prevents perfect gradient preservation across long sequences.
The knife-edge at spectral radius 1 is not a stable operating point. Small perturbations to from weight updates during training will push the spectral radius slightly above or below 1, and the gradient behavior will shift accordingly. Maintaining the spectral radius precisely at 1 would require a constraint on the optimization, and such constraints typically slow convergence and limit the expressiveness of the network.