Activation Functions › Leaky ReLU and PReLU

Michael BrenndoerferApril 21, 20255 min read
Language AI HandbookAll chapters
Part 10 of 67Neural Network Foundations
Chapter 62Activation Functions › Leaky ReLU and PReLU
Reading section 4 of 16 · Leaky ReLU and PReLU · 5 minSection 4 of 16 · 5 min

Book contents

Section 4 of 16 · 5 min read

Activation Functions › Leaky ReLU and PReLUOne section · Sections in this chapter4 / 16 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Both Leaky ReLU and Parametric ReLU (PReLU) address the dying neuron problem by ensuring that negative pre-activations still produce a nonzero gradient during backpropagation. They differ in whether the negative-side slope is fixed or learned.

Leaky ReLU

Leaky ReLU introduces a small slope on the negative side, so the gradient never completely vanishes:

LeakyReLU(z)={zif z>0αzif z≤0\text{LeakyReLU}(z) = \begin{cases} z & \text{if } z > 0 \\ \alpha z & \text{if } z \leq 0 \end{cases}

where:

  • zz: the pre-activation value
  • α\alpha: a small positive constant controlling the negative slope, typically α=0.01\alpha = 0.01

The derivative is:

d LeakyReLU(z)dz={1if z>0αif z≤0\frac{d\,\text{LeakyReLU}(z)}{dz} = \begin{cases} 1 & \text{if } z > 0 \\ \alpha & \text{if } z \leq 0 \end{cases}

With α=0.01\alpha = 0.01, the negative slope sends a gradient of 0.01 back through a dead neuron on every backward pass. The neuron can now gradually revive as its weights receive small but nonzero updates. In practice, Leaky ReLU often trains slightly faster than ReLU and effectively eliminates permanently dead neurons. The tradeoff is a small loss of the sparsity property: neurons no longer output exactly zero for negative inputs, so the regularizing effect of sparsity is reduced.

The choice of α=0.01\alpha = 0.01 is a heuristic. Values between 0.01 and 0.1 are commonly used. Larger α\alpha values improve gradient flow more aggressively but at the cost of less sparsity and a less clean identity-like behavior on the positive side. Values above 0.3 start to resemble a linear function more than a rectifier.

PReLU

Parametric ReLU (PReLU) takes this further by making α\alpha a learnable parameter:

PReLU(z)={zif z>0αzif z≤0\text{PReLU}(z) = \begin{cases} z & \text{if } z > 0 \\ \alpha z & \text{if } z \leq 0 \end{cases}

where α\alpha is now a learned parameter updated by gradient descent alongside the other network weights. Each neuron can have its own α\alpha, or a single α\alpha can be shared across all neurons in a layer.

The gradient with respect to α\alpha for a neuron with negative input z<0z < 0 is:

∂L∂α=∂L∂a⋅z\frac{\partial L}{\partial \alpha} = \frac{\partial L}{\partial a} \cdot z

where:

  • LL: the loss function
  • aa: the neuron's output
  • zz: the pre-activation value (the input to the activation)

PReLU lets the network learn the optimal negative slope for each context. If the data does not benefit from negative activations, the learned α\alpha will approach zero, recovering ReLU behavior. If negative activations help, the network will use them. PReLU was introduced in the context of deep residual networks and showed small but consistent improvements over fixed Leaky ReLU in image recognition tasks. The extra parameters introduced by per-neuron α\alpha values are typically negligible compared to the weight matrices, so the parameter overhead is minimal.

Randomized Leaky ReLU

A related variant, Randomized Leaky ReLU (RReLU), samples α\alpha uniformly from a fixed interval during training, then uses a fixed value (the interval's mean) at test time. The stochastic negative slope acts as a regularizer. This provides some of the same benefit as dropout without zeroing entire neurons. RReLU has shown small gains in image recognition benchmarks and is a useful technique to know, though it is less commonly used than Leaky ReLU or PReLU in production architectures.

The following plots show how ReLU, Leaky ReLU, and ELU compare in both their function values and gradients:

Out[5]:
Visualization
Line plot of ReLU, Leaky ReLU, and ELU activation functions showing their shapes.
ReLU, Leaky ReLU (alpha=0.01), and ELU activation functions over the input range [-4, 4]. ReLU clips all negative values to zero. Leaky ReLU preserves a small negative slope. ELU smoothly saturates to -1 for large negative inputs, producing a near-zero mean output.
Line plot of ReLU, Leaky ReLU, and ELU derivatives highlighting gradient behavior.
ReLU, Leaky ReLU (alpha=0.01), and ELU activation functions over the input range [-4, 4]. ReLU clips all negative values to zero. Leaky ReLU preserves a small negative slope. ELU smoothly saturates to -1 for large negative inputs, producing a near-zero mean output.