Skip to main content

Loading the visual lab…

#activationNeural networks

Why an activation? ReLU, sigmoid, tanh, Leaky ReLU, GELU and the vanishing gradient.

What you'll play with

  1. Welcome to #activation. On screen, the sigmoid curve on [-5, 5] and a pink point at x = 2.5. A neuron computes f(Σ w·x + b). Without f, stacking ten layers is the same as composing ten linear functions… that is, a single linear function: a regression, unable to separate XOR. The activation is what makes the network non-linear.
  2. Push the point further right: type /x 4. Look at where f(x) lands, and above all by how much it moved.
  3. For learning, what matters is not f(x) but f'(x), the slope. This is what backpropagation multiplies layer after layer to send the error back. Show it: /derivative.
  4. Switch to ReLU: /function relu. Right of zero, the slope is 1 whatever the value of x: no saturation. This detail made it possible to train AlexNet in 2012 and relaunched all of deep learning.
  5. But ReLU has an Achilles heel. Place the point on the left: /x -2.
  6. Overlay all five functions: /compare. Spot GELU (light blue): smooth like sigmoid around zero, linear like ReLU on the right, slightly negative (dip at -0.17). This is the activation of transformers: BERT, GPT and most LLMs.
  7. Your turn: /function gelu then /x -0.75 (GELU dip), /function tanh then /x 0 (max slope = 1), /derivative to compare all five derivatives, /reset to start over. Next step: the #gradient-descent channel, where this slope becomes the direction weights move in.

Channel commands

  • /function <relu|sigmoid|tanh|leaky|gelu>Change the activation function being plotted.
  • /x <value -5..5>Move the pink point along the curve.
  • /derivativeShow or hide the derivative curve f'(x).
  • /compareOverlay the five functions, each in its own color.
  • /resetBack to sigmoid, x = 2.5, no derivative and no compare.

Glossary

Activation function
A non-linear function applied to a neuron's weighted sum. Without it, stacking layers collapses to a single linear function: this is what gives the network its power.
ReLU
max(0, x). Slope 1 to the right of zero (no saturation), 0 to the left. Fast and effective: the default activation of deep networks since 2012.
Sigmoid
1 / (1 + e^(−x)), output between 0 and 1. Saturates at both ends: the slope tends to 0 there, which starves the gradient in deep networks. Still useful as an output for a probability.
Tanh
Hyperbolic tangent, output between −1 and 1, centered at zero (better than sigmoid for hidden layers), but it saturates too.
Leaky ReLU
ReLU with a small slope (0.01) to the left of zero: a neuron is never fully "dead", it can always wake up.
GELU
A smooth activation x·Φ(x) (Φ = Gaussian CDF): close to ReLU on the right, slightly negative near zero. Used in BERT, GPT and most transformers.
Saturation
A zone where the function flattens: the derivative is almost zero and the learning signal stops flowing. Sigmoid and tanh saturate at the extremes.
Vanishing gradient
In backpropagation, derivatives multiply from layer to layer. If each is 0.1, ten layers give 10⁻¹⁰: the earliest layers no longer learn.
Dead neuron
A ReLU neuron whose pre-activation is always negative: output 0, gradient 0, it will never wake up. Leaky ReLU and a good initialization limit the problem.

Other channels in Neural networks

  • #neuronLet us break a neuron apart: inputs, weights, sum, activation.
  • #dropoutDropout regularization: the best friend of deep networks.
  • #activationWhy an activation? ReLU, sigmoid, tanh, Leaky ReLU, GELU and the vanishing gradient.
  • #gradient-descentLoss is a landscape. The gradient says which way is up, so we step the other way.
  • #backpropagationThe computation graph replayed backwards: each node receives ∂L/∂(itself) and the chain rule does the rest.
  • #overfittingA big model on few data points: the decision boundary twists until it memorizes the noise.
  • #cnn-filtersAn image is a grid of numbers. A 3×3 filter slides over it, multiplies, adds up: that is a convolution.
  • #is-it-einsteinIs it Einstein? Two faces go through the scanner of a network that learned only Einstein: Haythem → NO, Einstein → YES. Watching is free; touching is Premium.
  • #embeddings-3dA word becomes a vector: close in space = close in meaning, and you can do math on them.