The idea
The activation function plays two roles at once. Forward, it shapes what a layer can express — it is the only nonlinear ingredient in the network, the thing that stops a deep stack from collapsing into one affine map. Backward, it acts as a per-unit gradient gate: backprop multiplies by at every layer, so the derivative of your activation gets raised, roughly, to the power of your depth.
That second role decided the history. Classic squashing functions:
with derivatives and . Both saturate: for beyond a few units the derivative is essentially zero, and the unit goes silent in the backward pass. Stack ten such layers and the early ones starve.
ReLU, , broke the pattern by being piecewise linear: derivative exactly 1 whenever the unit is active — no shrinkage, no saturation on the positive side, trivially cheap. Its one failure mode is the dead unit: pre-activation negative for all inputs means zero output and zero gradient forever. Leaky ReLU ( for , ) and GELU (, the transformer default) keep a small signal alive on the negative side.
Worked example
How badly does sigmoid throttle the backward pass? Its derivative at a few points:
| (the maximum) | ||
Now chain layers together. The activation contributes one factor per layer, so the best possible activation-derivative product through sigmoid layers (every unit sitting exactly at ) is :
| Depth | Sigmoid best case | ReLU active path |
|---|---|---|
| 2 | ||
| 5 | ||
| 10 |
And that is the optimistic bound — with realistic pre-activations like the per-layer factor is nearer , giving at depth 10. A gradient that small, multiplied into a sane learning rate, moves first-layer weights by nothing. The same table for ReLU is just 1 at every depth along active paths — which is the honest one-table summary of why deep learning waited for ReLU.
Cheat sheet
| Name | Formula | Range | Derivative | Gotcha |
|---|---|---|---|---|
| Sigmoid | saturates both tails; not zero-centered | |||
| Tanh | still saturates | |||
| ReLU | or | dead units | ||
| Leaky ReLU | or | one more hyperparameter () | ||
| GELU | smooth, near 0/1 | costlier; transformer default | ||
| Softmax | simplex | — | output probabilities and internal normalized weighting, notably attention |
Decision rules
- Hidden layers: ReLU by default; GELU in transformers; Leaky ReLU if dead units bite.
- Output: linear (regression) / 1 sigmoid (binary) / softmax (one-of-K) / K sigmoids (multi-label).
- RNN internals: tanh states, sigmoid gates.
- Pair init with activation: He () for ReLU family, Xavier ( scale) for tanh/sigmoid.
Symptoms → fixes
- Early layers not learning, loss plateaus → saturating activations somewhere; swap to ReLU/GELU, add normalization or residuals.
- Many units permanently outputting 0 after LR spike → dead ReLUs; lower LR / warmup, He init, leaky variant.
- Multi-label task mysteriously forcing one label per example → softmax where per-label sigmoids belong.