Stack two linear layers: , then . Multiply it out and , which is a single linear layer with matrix . A hundred linear layers are still one linear layer. Depth only buys anything if something non-linear happens between layers. That something is the activation function.
The common activations
| activation | formula | notes |
|---|---|---|
| sigmoid | output in (0, 1); saturates at both ends; derivative at most 0.25. Now mostly used for output probabilities and gates. | |
| tanh | output in (−1, 1), zero-centred; still saturates. | |
| ReLU | the default since AlexNet (2012): cheap, gradient exactly 1 for . Units stuck at can "die". | |
| leaky ReLU | small slope (e.g. 0.01) for so units can't die. | |
| GELU | a smooth ReLU, used in BERT, GPT and most transformers. |
ReLU's success has a simple explanation: for positive inputs it passes gradients through unchanged, so deep stacks don't shrink them the way sigmoids do (each sigmoid multiplies the gradient by at most 0.25; ten of them, by at most ). It also makes networks piecewise linear: a ReLU network carves its input space into many linear regions.
Universal approximation
How much can one hidden layer do? The universal approximation theorem (Cybenko 1989 for sigmoids, Hornik 1991 more generally) says a network with one hidden layer and enough units can approximate any continuous function on a bounded region to any accuracy. That is reassuring, and also much weaker than it sounds:
- "Enough units" can mean exponentially many. Deeper networks can represent many functions with far fewer units than shallow ones.
- It says such weights exist, not that gradient descent will find them.
- It says nothing about generalising from finite data.
Activations are what make depth worthwhile. ReLU-like functions dominate because they keep gradients alive through many layers.