TL;DR
Training a deep network means sending a learning signal backwards from the loss, one layer at a time. At each layer the signal is multiplied by a local factor. If those factors are typically smaller than 1, the signal shrinks geometrically, so the early layers receive updates too small to matter and effectively stop learning.
This is the vanishing gradient problem. It is why deep networks were hard to train for a long time, and why ideas like better activations, careful initialisation, normalisation, and skip connections became standard.
Where you'll see it: in deep sigmoid networks that stall at the start of training, in recurrent networks that cannot remember what happened many steps ago, and in very deep plain stacks that get worse as you add layers.
Intuition
A whisper passed down a line
Picture a line of people passing a message backwards. Each person repeats it at half volume. The first person in line hears almost nothing by the time it reaches them. The message was not wrong; it just decayed on the way.
Backpropagation works the same way. The loss tells the last layer how wrong it was, and each layer passes a blame signal to the one before it, multiplied by how sensitive its own output was to its input. If each layer halves the blame, then after ten layers the first layer gets about one thousandth of it. Its weights barely move, while the last layers learn quickly. The network trains, but only its top few layers do real work.
flowchart RL L[Loss] --> A[Layer 10: large update] A -->|times factor below 1| B[Layer 9: smaller update] B -->|times factor below 1| C[Layer 8: smaller still] C -->|and so on| D[Layer 1: near zero update]
Why it appears with saturating activations
A sigmoid squashes any input into the range from 0 to 1. For large positive or negative inputs its curve is almost flat, and a flat curve has a slope near zero. The slope is the local factor that backpropagation multiplies in. Saturated units therefore pass almost no signal back, and the problem is worst exactly when units are confidently on or off.
The math
The chain rule through a deep network
Write a network as layers , where and is an activation applied elementwise. The loss is . The gradient of the loss with respect to an early weight is found with the chain rule:
Each factor is a Jacobian matrix, whose entries are the derivatives of each output of layer with respect to each output of layer . Ignoring the matrices for a moment and looking at a single unit, the product becomes
where is the pre-activation at layer and is the weight that connects it to the next layer. The gradient is a product of factors. If the typical size of each factor is , the gradient scales like . That is exponential in depth.
Why the sigmoid makes small
The sigmoid is . Its derivative is , which peaks at with value , and falls towards 0 as grows. So everywhere. Even with a perfect weight of 1 in every layer, each layer multiplies the gradient by at most a quarter. The derivative of peaks at 1, which helps, but it still falls to zero for large .
- sigmoid derivative
- tanh derivative
The ReLU and the weight scale
The ReLU, , has derivative exactly 1 for positive inputs and 0 otherwise. For active units the factor is , so only the weights decide the scale. Then the gradient scales like , which can still vanish if the weights are typically below 1 or explode if above 1. Good initialisation keeps the typical at a scale where the product stays near 1. Xavier and He initialisation set the variance of the weights from the layer width for this reason.
Recurrent networks are deep in time
A Recurrent Neural Network applies the same weight matrix at every time step . Unrolled over steps, a gradient from step back to step contains a product of Jacobians of the form . If the spectral norm of these (the largest factor by which the matrix can stretch a vector) is below 1, the gradient vanishes over long spans. Bengio, Simard and Frasconi showed in 1994 that this makes it hard for plain gradient descent to learn dependencies that span many time steps.
Worked examples
Suppose every layer's local factor is its best case, , which means each unit sits at and the weights are 1.
- One layer: the gradient is multiplied by .
- Two layers: .
- Five layers: , about one thousandth.
- Ten layers: , about one millionth.
Interpretation: even in this ideal case, the first layer of a ten-layer sigmoid network gets a gradient about a million times smaller than the last layer's. Its weights move a million times more slowly, so for practical purposes it is frozen.
Consider a deep linear chain with the same weight in every layer. After layers the gradient scales like .
- Weight : . The gradient is about 200 times smaller than at the top.
- Weight : . The gradient is about 117 times larger.
- Weight : the product stays exactly 1, which is the goal of careful initialisation.
Interpretation: a 10 percent change in each weight changes the signal at depth 50 by a factor of about 23,000 (). This is why the scale of the weights matters so much in deep networks, and why normalisation layers exist.
Tradeoffs and failure modes
| Symptom | Likely cause | Remedy |
|---|---|---|
| Loss flat from the first step; only top layers change | Saturated sigmoid or tanh units, or small weights | Use Rectified Linear Unit (ReLU) or a related activation; check initialisation |
| Training works for shallow nets and stalls as depth grows | Multiplicative decay across layers | Add [[residual-connection |
| Early layers have tiny gradient norms, activations drift in scale | Scale mismatch between layers | Batch Normalization or Layer Normalization |
| Recurrent net forgets anything older than a few steps | Long products of Jacobians through time | Gated cells such as Long Short-Term Memory |
| Gradients sometimes blow up, sometimes vanish | Weight scale drifts above or below 1 | Careful initialisation, plus Gradient Norm Clipping for explosions |
Two failure modes need care. First, measuring gradient norms is the quickest diagnosis: a layer whose gradient is 10^-6 of the top layer's is not learning, no matter what the loss curve does overall. Second, ReLU is not a cure on its own. Dead units output zero and pass no gradient at all, and a stack of ReLUs with badly scaled weights can still explode or vanish.
Skip connections are the most important modern fix. A residual block adds its input back to its output, so the derivative contains an identity term that does not shrink with depth. Gradients can reach early layers through the identity path even when the transformations in between are poor.
History
The problem was identified by Sepp Hochreiter in his 1991 diploma thesis, which analysed why error signals decay through time in recurrent networks. In 1994 Yoshua Bengio, Patrice Simard and Paolo Frasconi wrote a formal analysis showing that gradient descent struggles to learn long-term dependencies, and this became a standard reference.
Through the 1990s and 2000s deep networks were hard to train, and the problem was a big reason. Glorot and Bengio's 2010 paper on deep feedforward networks analysed how activations and gradients change scale across layers and proposed the initialisation that now bears Glorot's name. Glorot, Bordes and Bengio showed in 2011 that ReLU units made deep networks easier to train, and that caught on quickly.
Hochreiter and Schmidhuber's LSTM in 1997 was designed explicitly to solve this problem in recurrent networks, with a memory cell whose additive update lets gradients flow unchanged. In 2015 He and colleagues introduced residual networks, which won the ImageNet classification challenge that year and made very deep networks routine. Batch normalisation (2015) and He initialisation (2015) completed the toolkit that let depth scale.
Check yourself
QuestionIn one sentence, what does 'vanishing' mean in the vanishing gradient problem, and in which layers is it most damaging?Show answer
The gradient signal shrinks each time it passes back through a layer, so after many layers it is tiny. It is most damaging in the early layers, because they receive the smallest updates and are furthest from the loss.
QuestionWhy is the maximum of the sigmoid derivative 0.25, and what does that imply for a 10-layer stack with weights of 1?Show answer
is largest at , where , giving . Each layer multiplies the gradient by at most 0.25, so after ten layers the factor is at most .
QuestionA plain 50-layer network with weight 1.1 in every layer and one with weight 0.9 are both trained. Roughly how do their gradients at the first layer compare with the top layer?Show answer
With weight 1.1 the gradient is multiplied by , so the first layer gets a larger signal, which can explode. With weight 0.9 it is multiplied by , so the first layer gets about 1/200 of the signal. Both are bad. The fix is to keep the effective scale near 1, through initialisation and normalisation.
QuestionYou add residual connections to a very deep network and training starts working. Explain the mechanism in terms of the gradient.Show answer
A residual block computes , so its derivative contains an identity term, . The identity part passes the gradient back unchanged, so even if is small, the gradient reaching early layers is not multiplied down to near zero. The shortcut gives the signal a direct route to the early layers.
Sources
- Vanishing gradient problem, Wikipedia: https://en.wikipedia.org/wiki/Vanishing_gradient_problem
- Bengio, Simard, Frasconi, Learning long-term dependencies with gradient descent is difficult (1994): https://ieeexplore.ieee.org/document/279181
- Hochreiter and Schmidhuber, Long Short-Term Memory (1997): https://www.bioinf.jku.at/publications/older/2604.pdf
- He et al., Deep Residual Learning for Image Recognition (2015): https://arxiv.org/abs/1512.03385