Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.A one-way valve
ReLU is a one-way valve: positive signals pass through unchanged, negative ones are blocked. That is the whole activation: max(0, z). It is so simple that it is almost free to compute, and because positive signals are never squashed, gradients pass through active units at full strength. These two facts made very deep networks trainable.
ReLU and its close variants are the default activation in convolutional backbones for perception, in MLP heads and in many transformers’ feed-forward blocks. Its cheapness matters on embedded processors. Its failure mode, dead units, silently wastes capacity, so monitoring the fraction of dead units is part of training hygiene.
- 1. ReLU(−3) =
- 2. ReLU's slope for positive inputs is…
- 3. A dead ReLU unit…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Definition and properties by hand
- Definition: ReLU(z) = max(0, z). For (−1.5, 0, 2) the outputs are (0, 0, 2).
- Gradient: 1 for z > 0, 0 for z < 0, and by convention 0 at z = 0. An upstream gradient of 3 at z = (−1, 0, 0.5) passes as (0, 0, 3).
- Sparsity: with symmetric pre-activations, about half the outputs are exactly 0.
- Positive homogeneity: ReLU(cz) = c·ReLU(z) for c > 0.
- Piecewise-linear geometry: a layer of units ReLU(wᵢx + bᵢ) on a 1-D input has kinks at x = −bᵢ/wᵢ. With w = (1, 1, −2, 0.5) and b = (0, −1, 1, 3), the kinks inside [−1, 2] are at 0, 1 and 0.5 (the one at −6 is outside), giving 4 linear pieces.
- Dead unit: a unit whose pre-activation is negative on every example. In the batch [[1, −2, 0.5], [2, −0.1, −1], [−1, −3, 0.2]], unit 1 is dead.
- Initialisation: He initialisation (variance 2/fan-in) compensates for ReLU zeroing half its inputs (E0-7).
- 1. Expected fraction of zero outputs for symmetric pre-activations?
- 2. A unit with w = 2 and b = −4 has its kink at…
- 3. The weight variance that suits ReLU is…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Sparsity and dead units
Exercise 1. With He weights and zero biases, a 200-unit ReLU layer had 0.500 of its outputs at zero on 1000 random inputs, and no dead units. Setting 20 biases to −10 killed exactly those 20 units: they were zero on all inputs, and their gradient was identically zero, so no gradient step could ever revive them.
Why units die. A large gradient step can push a unit’s weights and bias so that wᵀx + b < 0 for all training inputs. After that, ReLU′ = 0 everywhere for this unit, so its weights never change again. Common causes:
- a learning rate that is too high;
- strongly negative bias initialisation;
- a shift in the input distribution;
- heavy L1 regularisation.
Mitigations.
- A smaller or warmed-up learning rate.
- Biases initialised at 0 or slightly positive (although exercise 2 found the latter does not help reliably).
- Normalisation layers, which re-centre the pre-activations.
- Variants with a nonzero negative-side slope: leaky ReLU, PReLU, ELU, GELU (E1-5 onward).
z = layer(x); dead = ((z > 0).sum(dim=0) == 0).float().mean() # monitor the fraction of dead units on a batch- 1. Why can a dead ReLU never recover by gradient descent?
- 2. Which change makes dying more likely?
- 3. Normalisation layers reduce dying by…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why ReLU helped deep learning.
- No saturation for z > 0: active units pass the gradient with factor 1, unlike sigmoid and tanh.
- Sparsity: only part of the network is active for each input, a cheap form of regularisation and disentangling (Glorot, Bordes and Bengio, 2011).
- Cheapness: one comparison.
Krizhevsky et al. (2012) reported ReLU networks training several times faster than tanh networks on ImageNet.
Expressivity. A ReLU network computes a continuous piecewise-linear function. The number of linear regions grows polynomially with width and exponentially with depth (Montúfar et al., 2014), and universal approximation holds (E0-5).
Optimisation geometry. ReLU networks are positively homogeneous in each unit (scale the input weights by c and the output weights by 1/c, and the function is unchanged). This creates flat directions in the loss, and it is why weight norms can drift without changing predictions.
Dying ReLU, quantified. Lu et al. (2020) showed that very deep, narrow ReLU networks with symmetric initialisation die at initialisation with probability approaching 1, collapsing to a constant function. Asymmetric initialisation or width avoids this.
Interview questions.
- Why is the ReLU derivative at 0 not a problem? It is a single point. Any value in [0, 1] is a valid subgradient, and frameworks use 0.
- When would you prefer GELU or SiLU to ReLU? In transformers and large models, where smooth activations train slightly better. On cheap hardware ReLU is often fine and faster.
- 1. Krizhevsky et al. found ReLU networks trained…
- 2. Positive homogeneity lets you rescale a unit's weights…
- 3. Deep narrow ReLU networks at initialisation can…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.What kills ReLU units?
History.
- K. Fukushima (1969, 1980) used rectifying units.
- R. Hahnloser et al. (2000) gave a biological motivation for rectification.
- V. Nair and G. Hinton (2010) used ReLU in restricted Boltzmann machines.
- X. Glorot, A. Bordes and Y. Bengio (2011) showed deep sparse rectifier networks.
- A. Krizhevsky, I. Sutskever and G. Hinton (2012) won ImageNet with ReLU (AlexNet).
Exercise 2. A 3-hidden-layer ReLU network (width 64) on spirals (600 points), trained with minibatch SGD (batch 32) for 300 steps. The table gives the fraction of hidden units dead on all training data after training, and the training accuracy per seed.
| learning rate | initial bias | dead hidden units | training accuracy per seed |
|---|---|---|---|
| 0.1 | 0 | 0.049 | 1.000, 0.997, 1.000 |
| 0.1 | +0.1 | 0.045 | 1.000, 0.997, 1.000 |
| 0.1 | −0.5 | 0.312 | 0.690, 0.443, 0.783 |
| 0.5 | 0 | 0.043 | 1.000, 1.000, 1.000 |
| 0.5 | +0.1 | 0.066 | 1.000, 1.000, 1.000 |
| 0.5 | −0.5 | 0.240 | 1.000, 0.992, 0.865 |
| 1.0 | 0 | 0.128 | 1.000, 1.000, 1.000 |
| 1.0 | +0.1 | 0.278 | 0.768, 0.998, 0.993 |
| 1.0 | −0.5 | 0.356 | 0.660, 0.942, 0.918 |
- Negative initial biases killed many units from the start (24–36%) and cost accuracy, badly at the smallest learning rate, which could not recover.
- A learning rate of 1.0 killed more units than 0.1 or 0.5 (13% even with zero biases). Accuracy survived here, because width 64 leaves spare capacity.
- A small positive bias did not help reliably. At learning rate 1.0 it gave more dead units (28%) and one failed run. This common folklore fix did not work in this test.
- Dead units are wasted capacity. In narrower networks, the same fractions would cost accuracy directly.
ReLU in AI, robotics and aerospace
- Perception backbones: ReLU CNNs (ResNet, YOLO-family) for object detection on drones, rovers and satellites.
- Embedded inference: ReLU’s single comparison and its sparsity make quantised integer inference simple and efficient on MCUs and FPGAs.
- Verification: piecewise-linear ReLU networks can be verified exactly with mixed-integer or SMT solvers, which is useful for certifying learned controllers.
References
- V. Nair, G. E. Hinton (2010). “Rectified linear units improve restricted Boltzmann machines.” Proc. ICML.
- X. Glorot, A. Bordes, Y. Bengio (2011). “Deep sparse rectifier neural networks.” Proc. AISTATS.
- A. Krizhevsky, I. Sutskever, G. E. Hinton (2012). “ImageNet classification with deep convolutional neural networks.” Advances in NeurIPS 25.
- L. Lu, Y. Shin, Y. Su, G. E. Karniadakis (2020). “Dying ReLU and initialization: theory and numerical examples.” Communications in Computational Physics 28(5).
- G. Montúfar, R. Pascanu, K. Cho, Y. Bengio (2014). “On the number of linear regions of deep neural networks.” Advances in NeurIPS 27.