Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.A valve that leaks
ReLU blocks negative inputs completely, which is how units die (E1-4). Leaky ReLU lets a little through: negative inputs are multiplied by a small slope a, such as 0.01 or 0.1, instead of zero. A unit that is “off” for every example still receives a small gradient and can be pulled back. PReLU goes one step further and learns the slope.
Leaky ReLU is a drop-in replacement for ReLU at the same cost, so it is a cheap insurance against dead units in detectors and GAN discriminators (where leaky ReLU with slope 0.2 is standard). The slope is a hyperparameter that matters more than its usual default suggests, as exercise 2 shows.
- 1. Leaky ReLU with slope 0.1 maps −5 to…
- 2. PReLU differs from leaky ReLU because…
- 3. The point of the leak is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Definitions and gradients by hand
- Leaky ReLU: f(z) = z for z > 0, a·z for z ≤ 0. With a = 0.1, (−2, −0.5, 0, 1.5) ↦ (−0.2, −0.05, 0, 1.5).
- Gradient: 1 for z > 0, a for z ≤ 0. An upstream gradient of 2 at z = −1 passes as 0.2 when a = 0.1.
- PReLU (He et al., 2015): the same function with a learned, usually per channel or shared within a layer. The slope’s gradient is ∂L/∂a = Σ (∂L/∂f)·min(z, 0). For upstream (1, 2, 3) at z = (−1, −0.5, 2), it is −1 − 1 + 0 = −2.
- Randomised leaky ReLU (RReLU): sample a ~ U(lo, hi) per element during training, and use (lo + hi)/2 at test time. For lo = 1/8, hi = 1/3, the test slope is 11/48 ≈ 0.229.
- Initialisation: He et al. derived Var(w) = 2/((1 + a²)·fan-in). For fan-in 50 and a = 0 the standard deviation is 0.2. For a = 1 the function is linear and the variance is 1/fan-in.
- Geometry: leaky ReLU is still positively homogeneous, f(cz) = c·f(z) for c > 0, and still piecewise linear.
- 1. Leaky ReLU with a = 1 is…
- 2. Leaky ReLU with a = −1 is…
- 3. The PReLU slope gradient sums upstream times…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Gradients that never vanish completely
Exercise 1. The leaky ReLU and PReLU gradients agree with finite differences. A unit whose bias was set to −10 was inactive on all 500 inputs:
- under ReLU its bias gradient was exactly 0;
- under leaky ReLU with a = 0.1 it was 0.1 per example (50 in total for upstream 1).
The leaky unit can therefore move back toward the data.
Choosing the slope.
- a = 0.01 is the common default (Maas et al., 2013), and it keeps the function close to ReLU.
- Larger slopes, 0.1 to 0.3, give stronger recovery signals and were found to work better in Xu et al.’s (2015) comparison.
- GAN discriminators use 0.2.
- If the slope is too large, the nonlinearity weakens toward linear, and in a trial at learning rate 1.0, slopes 0.1 and 0.3 each diverged in one of three seeds.
PReLU in practice.
- Do not apply weight decay to a, since it would push a toward 0, back to ReLU.
- Use one slope per channel (in CNNs) or one per layer (channel-shared).
- He et al. found learned slopes to be larger in early layers.
nn.LeakyReLU(0.1) # fixed slope
nn.PReLU(num_parameters=C) # learned slope per channel, initialised at 0.25- 1. Why not apply weight decay to PReLU slopes?
- 2. GAN discriminators commonly use a leaky slope of…
- 3. He initialisation for leaky slope a uses variance…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Variance propagation. For symmetric pre-activations z with variance v, E[f(z)²] = (1 + a²)·v/2. Keeping the forward variance constant therefore needs fan-in·Var(w)·(1 + a²)/2 = 1, which gives He et al.’s formula. It reduces to He for a = 0 and to LeCun (1/fan-in) for a = 1.
PReLU gradient. Since f(z) = max(0, z) + a·min(0, z), ∂f/∂a = min(0, z). With a shared slope, the gradients from all positions in the layer are summed. That sum can be large, so implementations treat a like any other parameter, and in exercise 2 the raw summed gradient at learning rate 0.1 to 1.0 pushed slopes out of range. The exercise therefore averages over units and clamps a to [0, 1].
Results.
- He et al. (2015) reported PReLU reducing ImageNet top-1 error by about 1.2 points over ReLU in a 14-layer network, at negligible cost, and became the first to surpass the reported human-level error on ImageNet classification.
- Xu et al. (2015) compared ReLU, leaky ReLU, PReLU and RReLU on CIFAR and found leaky variants, especially RReLU, better than ReLU on small data, where the randomness acts as a regulariser.
When the leak does not matter. With normalisation layers and sensible initialisation and learning rates, units rarely die, and plain ReLU performs about as well. The leak matters most without normalisation, at high learning rates, or after bad initialisation.
- 1. ∂f/∂a for PReLU at z = −3 is…
- 2. RReLU's randomness was found to act as…
- 3. With batch normalisation and good initialisation, the advantage of the leak is usually…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Does a leak rescue dying networks?
History.
- A. Maas, A. Hannun and A. Ng (2013) introduced leaky ReLU (slope 0.01) for speech recognition.
- K. He, X. Zhang, S. Ren and J. Sun (2015) introduced PReLU and the matching initialisation.
- B. Xu, N. Wang, T. Chen and M. Li (2015) proposed randomised leaky ReLU and compared the rectifiers.
- A. Radford, L. Metz and S. Chintala (2016) made leaky ReLU with slope 0.2 standard in GAN discriminators (DCGAN).
Exercise 2. The worst setting of E1-4: a 3-hidden-layer network (width 64) on spirals, hidden biases initialised at −0.5, minibatch SGD for 300 steps. Only the activation’s negative slope changes. “Inactive” means the unit’s pre-activation is never positive on the training data. For a leaky unit this is not dead, since it still receives gradient, but it computes a linear function of its input. The PReLU slope gradient is averaged over units and clamped to [0, 1].
| activation | learning rate | inactive units | training accuracy per seed | final slope |
|---|---|---|---|---|
| ReLU | 0.1 | 0.312 | 0.690, 0.443, 0.783 | 0 |
| ReLU | 0.5 | 0.240 | 1.000, 0.992, 0.865 | 0 |
| leaky 0.01 | 0.1 | 0.318 | 0.705, 0.448, 0.790 | 0.01 |
| leaky 0.01 | 0.5 | 0.233 | 1.000, 0.988, 0.652 | 0.01 |
| leaky 0.1 | 0.1 | 0.205 | 0.682, 0.840, 0.763 | 0.1 |
| leaky 0.1 | 0.5 | 0.177 | 0.945, 0.990, 0.988 | 0.1 |
| leaky 0.3 | 0.1 | 0.111 | 0.970, 0.982, 0.972 | 0.3 |
| leaky 0.3 | 0.5 | 0.083 | 0.997, 0.937, 1.000 | 0.3 |
| PReLU (from 0.1) | 0.1 | 0.186 | 0.740, 0.825, 0.765 | 0.148 |
| PReLU (from 0.1) | 0.5 | 0.167 | 0.998, 0.992, 0.998 | 0.126 |
- The default slope 0.01 did nothing measurable. Its results were within 0.03 of plain ReLU in every column. A gradient of 1% of normal is too weak to revive units in 300 steps.
- Slope 0.3 fixed the problem. It left a third as many inactive units, and accuracy rose from 0.44–0.78 to 0.97–0.98 at the small learning rate.
- PReLU moved its slope up, from 0.1 to about 0.13–0.15. It did better than a fixed 0.1, but in 300 steps it did not reach the slope that worked best.
- The slope is a hyperparameter worth tuning when units are dying. In a trial at learning rate 1.0, slopes 0.1 and 0.3 each diverged in one of three seeds, so a leak is not a substitute for a sensible learning rate.
Leaky ReLU in AI, robotics and aerospace
- Detectors: YOLO v1–v3 used leaky ReLU (slope 0.1) throughout, and these detectors were widely deployed on drones and robots.
- Generative models: GAN discriminators for synthetic sensor data and simulation-to-real transfer use slope 0.2.
- Small-data regimes: where labelled flight or robot data are scarce, the regularising effect of RReLU can help.
References
- A. L. Maas, A. Y. Hannun, A. Y. Ng (2013). “Rectifier nonlinearities improve neural network acoustic models.” ICML Workshop on Deep Learning for Audio, Speech and Language Processing.
- K. He, X. Zhang, S. Ren, J. Sun (2015). “Delving deep into rectifiers: surpassing human-level performance on ImageNet classification.” Proc. ICCV.
- B. Xu, N. Wang, T. Chen, M. Li (2015). “Empirical evaluation of rectified activations in convolutional network.” arXiv:1505.00853.
- A. Radford, L. Metz, S. Chintala (2016). “Unsupervised representation learning with deep convolutional generative adversarial networks.” Proc. ICLR.