๐Ÿงฎ Brain Teaser

The Vanishing Gradient Plateau: Why Sigmoid Networks Saturate

Consider a single neuron with sigmoid activation ฯƒ(z)=11+eโˆ’z\sigma(z) = \frac{1}{1+e^{-z}}, where z=wx+bz = w x + b.

Training uses gradient descent on the squared loss L=12(yโˆ’ฯƒ(z))2L = \frac{1}{2}(y - \sigma(z))^2 for a single training example (x,y)(x, y).

(a) Show that the gradient โˆ‚Lโˆ‚w\frac{\partial L}{\partial w} contains the factor ฯƒ(z)(1โˆ’ฯƒ(z))\sigma(z)(1-\sigma(z)).

(b) Now suppose the network is initialized with a large weight โˆฃwโˆฃโ‰ซ1|w| \gg 1 and x=1x = 1, y=0y = 0. Argue clearly: even though the network is making a large error (since ฯƒ(z)โ‰ˆ1\sigma(z) \approx 1 but y=0y = 0), learning is extremely slow. What is the maximum possible value of ฯƒ(z)(1โˆ’ฯƒ(z))\sigma(z)(1-\sigma(z)), and where is it achieved?

(c) This is the vanishing gradient / saturation phenomenon. Give a one-sentence intuition for why the sigmoid's shape causes this, and name one architectural change that mitigates it.

neural networkssigmoidvanishing gradientbackpropagationactivation functions

Answer: The Vanishing Gradient Plateau: Why Sigmoid Networks Saturate

Key Idea / Intuition

The sigmoid function "squashes" its input into (0,1)(0,1), which is great for probability interpretation โ€” but the price is that its derivative ฯƒโ€ฒ(z)=ฯƒ(z)(1โˆ’ฯƒ(z))\sigma'(z) = \sigma(z)(1-\sigma(z)) is nearly zero whenever โˆฃzโˆฃ|z| is large. So when a neuron is confidently wrong (output near 0 or 1), the gradient almost vanishes, and weights barely move. The network is stuck in a flat landscape of its own making.


Formal Proof / Solution

Part (a): Computing the gradient

By the chain rule:

โˆ‚Lโˆ‚w=โˆ‚Lโˆ‚ฯƒโ‹…โˆ‚ฯƒโˆ‚zโ‹…โˆ‚zโˆ‚w\frac{\partial L}{\partial w} = \frac{\partial L}{\partial \sigma} \cdot \frac{\partial \sigma}{\partial z} \cdot \frac{\partial z}{\partial w}

Each factor:

  • โˆ‚Lโˆ‚ฯƒ=โˆ’(yโˆ’ฯƒ(z))\frac{\partial L}{\partial \sigma} = -\bigl(y - \sigma(z)\bigr)
  • โˆ‚ฯƒโˆ‚z=ฯƒ(z)(1โˆ’ฯƒ(z))\frac{\partial \sigma}{\partial z} = \sigma(z)\bigl(1 - \sigma(z)\bigr) (standard sigmoid derivative)
  • โˆ‚zโˆ‚w=x\frac{\partial z}{\partial w} = x

So:

โˆ‚Lโˆ‚w=โˆ’(yโˆ’ฯƒ(z))โ€‰ฯƒ(z)(1โˆ’ฯƒ(z))โ€‰x\boxed{\frac{\partial L}{\partial w} = -\bigl(y - \sigma(z)\bigr)\,\sigma(z)\bigl(1-\sigma(z)\bigr)\,x}

The factor ฯƒ(z)(1โˆ’ฯƒ(z))\sigma(z)(1-\sigma(z)) appears explicitly.


Part (b): Large error yet slow learning

With wโ‰ซ1w \gg 1, x=1x = 1, y=0y = 0: we have z=wโ‰ซ1z = w \gg 1, so ฯƒ(z)โ‰ˆ1\sigma(z) \approx 1.

  • Error: L=12(0โˆ’ฯƒ(z))2โ‰ˆ12L = \frac{1}{2}(0 - \sigma(z))^2 \approx \frac{1}{2}. This is a large error (the neuron is outputting โ‰ˆ1\approx 1 when the target is 00).

  • Gradient factor: ฯƒ(z)(1โˆ’ฯƒ(z))โ‰ˆ1โ‹…(1โˆ’1)โ‰ˆ0\sigma(z)(1-\sigma(z)) \approx 1 \cdot (1-1) \approx 0.

So the gradient โˆ‚Lโˆ‚wโ‰ˆโˆ’(0โˆ’1)(0)(1)=0\frac{\partial L}{\partial w} \approx -(0-1)(0)(1) = 0. Learning is essentially frozen despite the large loss.

Maximum of ฯƒ(z)(1โˆ’ฯƒ(z))\sigma(z)(1-\sigma(z)):

Let s=ฯƒ(z)โˆˆ(0,1)s = \sigma(z) \in (0,1). We maximize f(s)=s(1โˆ’s)f(s) = s(1-s) by AM-GM or calculus:

fโ€ฒ(s)=1โˆ’2s=0โ€…โ€ŠโŸนโ€…โ€Šs=12f'(s) = 1 - 2s = 0 \implies s = \frac{1}{2}

fโ€‰โฃ(12)=14f\!\left(\tfrac{1}{2}\right) = \tfrac{1}{4}

So the maximum gradient factor is 14\frac{1}{4}, achieved when z=0z = 0 (the neuron is exactly at the decision boundary, outputting 12\frac{1}{2}).

This means even in the best case, back-propagating through a sigmoid layer multiplies the gradient by at most 14\frac{1}{4}. With many layers, this compounds: through LL layers, the gradient can shrink by up to (1/4)L(1/4)^L.


Part (c): Intuition and fix

Intuition: The sigmoid flattens out at both ends of its S-curve; a neuron that has made up its mind (output near 0 or 1) sits in a flat region where infinitesimal changes to the weight produce infinitesimal changes in output, killing the learning signal.

Fix: Replace sigmoid with ReLU (maxโก(0,z)\max(0, z)), whose derivative is either 00 or 11 โ€” it doesn't saturate for positive inputs, so gradients flow through cleanly (at the cost of "dying ReLU" for negative inputs, addressed by Leaky ReLU or ELU).


Summary Table

| Quantity | Value | |---|---| | Max of ฯƒ(z)(1โˆ’ฯƒ(z))\sigma(z)(1-\sigma(z)) | 1/41/4 at z=0z=0 | | Value when zโ‰ซ1z \gg 1 | โ‰ˆ0\approx 0 | | Gradient at large ww | โ‰ˆ0\approx 0 despite large loss | | Per-layer gradient decay | up to factor 1/41/4 |

Written to: questions/2026-06-17_am.md

Source: The Elements of Statistical Learning, Ch. 11 (Hastie, Tibshirani, Friedman)

Type: ML/StatsSource: The Elements of Statistical Learning, Ch. 11 (Hastie, Tibshirani, Friedman)Edit on GitHub โ†—