The ReLU activation function — short for Rectified Linear Unit — is the default activation for hidden layers in modern neural networks. It is almost absurdly simple: it returns the input if the input is positive, and zero otherwise. That simplicity is exactly why it trains fast and largely fixed the vanishing-gradient problem that held deep networks back for years.

Try it: interactive ReLU plot
The blue line is the ReLU activation function; the orange dashed line is its derivative. Notice the derivative is a clean 0 or 1 — no tiny gradients to vanish.
The ReLU formula
The derivative is equally simple: 1 for positive inputs and 0 for negative inputs (undefined exactly at zero, where libraries just pick 0). Because the gradient is a full 1 in the active region, error signals flow backward through many layers without shrinking — the core reason the ReLU activation function unlocked deep learning.
How the ReLU activation function changed deep learning
Before 2012, most networks used sigmoid or tanh, and training anything more than a few layers deep was painful: gradients shrank toward zero as they propagated backward, so early layers barely learned. When AlexNet won the ImageNet competition using the ReLU activation function throughout its hidden layers, the field noticed. ReLU let gradients pass at full strength through the active half of every neuron, so very deep convolutional networks suddenly became trainable in reasonable time. Today ReLU and its variants are the default choice for the hidden layers of almost every convolutional and feed-forward architecture, and understanding it is the natural first step into every other activation function.
Why ReLU became the default
The dying ReLU problem
ReLU vs sigmoid and tanh
| Property | ReLU | Sigmoid / Tanh |
|---|---|---|
| Output range | [0, ∞) | (0,1) / (−1,1) |
| Saturates? | Only for x < 0 | Both tails |
| Vanishing gradient | Largely avoided | Severe in deep nets |
| Cost | 1 comparison | exp() call |
For hidden layers, ReLU almost always wins. You still use sigmoid for a binary output and softmax for multi-class output.
ReLU in Python
import numpy as np
def relu(x):
return np.maximum(0, x)
def relu_derivative(x):
return (x > 0).astype(float)
print(relu(np.array([-2.0, -0.5, 0.0, 1.5, 3.0])))
# [0. 0. 0. 1.5 3. ]In PyTorch it is torch.nn.ReLU(); in TensorFlow/Keras, activation="relu". See the Wikipedia rectifier article for the mathematical background.
Frequently asked questions
Why is the ReLU activation function better than sigmoid?
Where should I use ReLU?
What is dying ReLU?
Related activation functions
- Activation Functions — the complete guide (hub).
- Leaky ReLU — fixes dying ReLU.
- Sigmoid Function — for binary outputs.
- Vanishing Gradient Problem — what ReLU solves.