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.

Not startedJump to quiz

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

110⁻²10⁻⁴10⁻⁶1246810number of sigmoid layers the signal passes throughlargest possible factor
sigmoid: 0.25ⁿReLU (active units): 1ⁿ = 1
The activation-derivative part of the gradient shrinks geometrically with depth for sigmoid units (log scale). Actual gradients also depend on the weights.

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

Backprop multiplies one per layer. Sigmoid , so 10 layers give . ReLU ( when active) avoids the shrinkage.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1calculateBackpropagating through 10 sigmoid layers multiplies 10 activation derivatives. What is the largest that product can be?
Q2interpretIn a deep sigmoid network, the last layers' weights change quickly but the first layers' barely move. What explains it?
Q3applyWhich change most directly reduces vanishing gradients in a deep network?
Q4conceptHow does saturation make vanishing gradients worse?
Q5conceptIn the recursion , what does contain?