3.1.5 · D2Neural Network Fundamentals

Visual walkthrough — ReLU and variants (Leaky ReLU, ELU, GELU)

2,051 words9 min readBack to topic

We start from literally nothing: a dot on a number line.


Step 1 — What "activation" even means

WHAT. A neuron first computes one number. It takes its inputs, multiplies each by a weight, adds them up, adds a bias, and gets a single value we call . That is called the pre-activation. Then a function turns into the neuron's output .

WHY we need at all. If just handed back unchanged (), stacking neurons would give you one big straight-line map — no curves, no learning of complicated shapes. (The parent proves this collapse: .) So must bend.

PICTURE. Below, one number enters on the left axis, a function box bends it, and comes out. The number line at the bottom is our entire universe for now: every input is just a position, negative on the left, positive on the right.

Figure — ReLU and variants (Leaky ReLU, ELU, GELU)

Step 2 — The hard gate: ReLU

WHAT. The simplest useful bend: if is positive, keep it; if is negative, output . Read as "whichever is larger, or ". When , is larger, so you get . When , is larger, so you get .

WHY this shape. It is the cheapest possible non-linearity — one comparison, no , no division. The kink at (where the graph changes direction) is the genuine non-linear feature: two straight pieces meeting at a corner is not a straight line.

PICTURE. Look at the graph. To the right of the red line is exactly the diagonal . To the left it lies flat on the floor . The corner is marked in yellow — that corner is where the "power" lives.

Figure — ReLU and variants (Leaky ReLU, ELU, GELU)

Step 3 — The slope story (why gradients care)

WHAT. During learning, a network passes a correction signal backward. At each activation, that signal gets multiplied by the slope of at the point . Slope = "how steep is the graph right here" = the derivative .

WHY slope, not value. The learning rule (see Backpropagation) chains slopes together. If a slope is , the correction gets multiplied by and dies — no update reaches earlier layers. This is the whole drama.

For ReLU the slope is dead simple:

PICTURE. Two flat plateaus: slope on the right (signal passes untouched), slope on the left (signal blocked). Compare the pale sigmoid slope curve underneath — it never even reaches , so deep stacks of it shrink the signal toward nothing (the vanishing gradient disease). ReLU's flat is the cure.

Figure — ReLU and variants (Leaky ReLU, ELU, GELU)
Recall Why is slope

so precious? Multiplying a backward signal by many times leaves it unchanged; multiplying by many times shrinks it toward . ::: ReLU keeps deep signals alive because its active-region slope is exactly .


Step 4 — The disaster: dying ReLU (the degenerate case)

WHAT. Suppose a neuron's is always negative (say a big negative bias pushed it there). Then its output is always and its slope is always . No output, no backward signal, no update — forever.

WHY it is permanent. To escape the negative region the weights would need to change; but they only change when a gradient flows; but the gradient is because it is negative. The neuron is trapped. This is the dying ReLU problem, and it is the entire reason the variants exist.

PICTURE. A red dot sits deep in the negative zone. Both arrows above it — output arrow and gradient arrow — read . The neuron is a dead pipe.

Figure — ReLU and variants (Leaky ReLU, ELU, GELU)

Step 5 — First fix: Leaky ReLU tilts the floor

WHAT. Instead of a flat floor, give the negative side a tiny downward slope : Here is a small fixed number. On the negative side the output is — a gentle slope instead of dead flat.

WHY it revives neurons. Now the slope on the left is , not : A tiny non-zero gradient still flows, so a stuck neuron can slowly crawl back toward positive territory.

PICTURE. The floor is no longer flat — it tilts slightly below zero (green line). The same negative dot from Step 4 now has a non-zero gradient arrow. Barely alive is still alive.

Figure — ReLU and variants (Leaky ReLU, ELU, GELU)

Step 6 — Smooth fix: ELU rounds the corner with an exponential

WHAT. Replace the negative straight piece with a curve that bends up from and flattens: Read the negative piece: is the exponential (grows/shrinks smoothly, always positive); subtract so that at we get — it meets the positive piece exactly. As , , so the curve saturates to .

WHY an exponential and not a line. Two wins a straight leak can't give:

  • Bounded negatives. The Leaky line keeps diving down forever; levels off at , so a very noisy negative input can't produce a huge negative output.
  • Smooth corner. Its slope on the left is , which at equals . With that is exactly — the same slope as the right piece, so no abrupt corner (unlike ReLU/Leaky, which change slope suddenly at ).

PICTURE. The blue ELU curve glides smoothly through the origin and flattens onto the dashed line far to the left. No kink; a rounded valley.

Figure — ReLU and variants (Leaky ReLU, ELU, GELU)
Recall Why subtract the

in ? So the curve passes through and joins the positive piece with no jump. ::: At , , matching -style continuity.


Step 7 — Probabilistic fix: GELU, a soft gate

WHAT. Instead of a hard "keep or drop", weight the input by the probability it should be kept: Here is the standard normal CDF: the chance that a random standard Gaussian lands at or below . It rises smoothly from (far left) through (at ) to (far right).

WHY multiply by . ReLU multiplies by a hard gate — if , else . GELU replaces that step-jump with a smooth S-shaped gate: the bigger is, the more likely we keep it. The output is the expected value of a stochastic on/off gate — a soft ReLU.

Trace the three regimes:

  • Small : , output — gentle.
  • Large positive : , output (like ReLU).
  • Large negative : , output — but smoothly, dipping slightly negative just left of the origin.

PICTURE. Yellow S-curve = the gate ; red curve = the product . Notice the tiny negative dip near where a small meets a still-nonzero .

Figure — ReLU and variants (Leaky ReLU, ELU, GELU)

Step 8 — All four on one axis (the case sweep)

WHAT. Put every function on the same picture and read off what each does with a negative input — the case that separates them.

WHY. Every neuron's can be positive, zero, or negative. On the positive side all four agree (). All the design choices live on the negative side:

Function output slope negative dead?
ReLU yes (dies)
Leaky no
ELU , saturates to no
GELU , tiny dip then smooth no

PICTURE. Four coloured curves overlaid. Right half: they merge into the one diagonal. Left half: they fan out — flat (ReLU), tilted (Leaky), curved valley (ELU), soft dip (GELU).

Figure — ReLU and variants (Leaky ReLU, ELU, GELU)

The one-picture summary

WHAT. One figure holds the whole story: the shared positive diagonal, the four negative-side treatments, and — underneath — the four slopes at a deeply negative point, showing which neurons can still learn.

Figure — ReLU and variants (Leaky ReLU, ELU, GELU)

The top panel is the family of shapes; the bottom bar chart is the punchline — at , ReLU's learning slope is a dead while Leaky/ELU stay alive. That single gap is why the family exists.

Recall Feynman retelling of the whole walkthrough

A neuron makes one number and must decide what to send onward. ReLU is a one-way gate: push forward, water flows; push backward, it slams shut — and once shut with no push, it's a dead pipe forever, because the "how much would opening help" signal is also zero. So we tinker with the backward side. Leaky cuts a hairline crack so a trickle always leaks and the pipe stays revivable. ELU replaces the crack with a smooth curved wall that lets a little backward flow but never floods — it levels off. GELU is the smartest gate: it opens more the harder the water pushes, deciding softly instead of all-or-nothing, using "how likely should I keep this?" as its opening amount. On the forward (positive) side, all four behave identically — a plain open channel . Every clever idea is spent on the negative side, and it's all about one thing: never let the backward learning signal become exactly zero.

Connections