25 November 2026 · 3 min readInteractive 3D
Sigmoid or ReLU: which activation function?
Without activation functions, a deep network collapses into one straight line. Compare the two most famous ones in 3D.
Each neuron ends with an activation function that bends its output. Without that bend, stacking layers would be pointless: many straight-line steps in a row are still just one straight line. The bend is what lets networks learn curves.
Sigmoid: the smooth S
Sigmoid squeezes any number into the range 0 to 1, with a smooth S-shaped step. It is handy when you want a probability, such as “how likely is this email to be spam?” Its weakness is the flat ends: far from the middle, the slope is almost zero, so learning slows to a crawl in deep networks.
ReLU: the ramp
ReLU, the rectified linear unit, is even simpler: negative numbers become 0, positive numbers pass straight through. It never flattens out on the positive side, so gradients flow well through many layers. That simple property helped make deep networks practical, and ReLU and its cousins are now the usual choice inside networks.
- Sigmoid: smooth, output between 0 and 1, good for final probabilities.
- ReLU: a sharp bend at 0, fast and simple, good for hidden layers.
The two formulas, worked out
- Sigmoid: σ(x) = 1 ÷ (1 + e⁻ˣ)
- σ(0) = 0.5, σ(2) ≈ 0.88, σ(−2) ≈ 0.12
- ReLU: max(0, x)
- ReLU(2) = 2, ReLU(−2) = 0
The vanishing gradient problem
The slope of the sigmoid is at most 0.25, and far from zero it is almost flat. In a deep network, learning multiplies slopes layer by layer, so with sigmoids the signal shrinks to almost nothing before it reaches the first layers: 0.25 × 0.25 × 0.25 × 0.25 is already under 0.004. Those early layers barely learn. ReLU has slope exactly 1 for positive inputs, so the signal passes through undiminished.
That simple change, around 2010, was one of the reasons deep networks suddenly became trainable.
Which to use when
- ReLU (or a smooth version like GELU) in hidden layers of most networks.
- Sigmoid at the output when the answer is a probability of yes or no.
- Softmax at the output when choosing between several classes.
ReLU’s weakness: a neuron whose input is always negative outputs 0 and stops learning. Leaky ReLU gives negative inputs a small slope to avoid this.
Why any bend is needed
Without activation functions, stacking layers would be pointless: a matrix followed by a matrix is just one matrix, so a hundred layers would equal one straight-line model. The bend is what lets depth add power.
Glossary
- Activation: the output of a neuron after the bend.
- Vanishing gradient: learning signals shrinking through layers.
- Dead neuron: a ReLU unit stuck at zero.
Try these yourself
- Q1. ReLU(−3) = 0 and ReLU(3) = 3
- Q2. σ(0) = 0.5
- Q3. Slope of ReLU at x = 5: 1
- Q4. Five sigmoid layers each with slope 0.25: 0.25⁵ ≈ 0.001, almost nothing passes back
Other activations you may see
- Tanh: like sigmoid but from −1 to 1.
- Leaky ReLU: a small slope for negative inputs.
- GELU: a smooth ReLU used in transformers.
- Softmax: turns a list of scores into percentages.
In short
Use ReLU-style activations inside networks so learning signals pass through; use sigmoid or softmax at the output to give probabilities.
Keep going
Questions people ask
What is the difference between sigmoid and ReLU?
Sigmoid squashes any number into 0 to 1 with an S-curve; ReLU keeps positive numbers and turns negative ones into 0.
Why is ReLU used more than sigmoid?
It is faster to compute and does not shrink gradients for positive inputs, so deep networks train much better.
When should you use sigmoid?
At the output of a model that predicts a probability for a yes-or-no question.