Lesson 4.2 · 7 min read · about 50 min to master at a very slow pace
Vanishing Gradients
Why early layers of a deep sigmoid network barely learn: backpropagation multiplies one activation derivative per layer, and sigmoid derivatives are at most 0.25. The numbers, the mechanism and the fixes.
The mechanism
Backpropagation (Section 7) carries the error signal from the output back to earlier layers. At each layer it is multiplied by a transposed weight matrix and by the activation derivative. Written compactly, with :
For sigmoid units, every factor is at most 0.25. Ten such factors give at most
So the output layers keep learning while the first layers receive almost no update. Saturation makes it worse: a unit with a large has far below 0.25.
Remedies
- ReLU in hidden layers: its derivative is exactly 1 for active units, so the activation doesn't shrink the signal.
- Careful initialisation (for example He initialisation for ReLU) and normalised inputs, so units start out of saturation.
- Architectural fixes for very deep networks, such as batch normalisation and residual connections (beyond this course).
Exam phrasing
"The sigmoid derivative is at most 0.25, so backpropagating through many sigmoid layers multiplies many small factors and the gradients reaching early layers shrink towards zero. ReLU's derivative is 1 for positive inputs, so it doesn't shrink the signal."
Stuck? Common doubts
Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.
Going deeperCan gradients also become too large?
Yes. If the weights are large, the product of weight matrices can grow with depth instead of shrinking: exploding gradients, which make training unstable. Sensible initialisation keeps the products near 1 in both directions, and gradient clipping is a common safety net.
First passIf the earliest layers get tiny gradients, what about the later layers?
The later layers are fine. A layer's gradient is a product of one slope per layer between it and the output, so layers near the output multiply only a few small factors, and layers near the input multiply many.
With sigmoid slopes of at most 0.25: one layer back, the gradient is scaled by 0.25; five layers back, by . So the last layers keep learning while the first layers barely move from their random starting weights, and the network behaves as if it were much shallower.
ReLU helps because its slope is exactly 1 for positive inputs, so the product doesn't shrink.
Cheatsheet
Vanishing gradients
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.