Activation functions

Level UniversityDifficulty ★★★★★Application⌖ Open in the map

What is it?

The non-linear functions applied after each linear layer. Without them a deep network collapses to one linear map. Their derivatives matter as much as their values: sigmoids saturate (vanishing gradients), ReLU passes gradients unchanged where active.

Formulas

σ(z)=11+e−z,tanh⁡z,ReLU⁡(z)=max⁡(0,z),GELU⁡(z)=z Φ(z)\sigma(z) = \frac{1}{1 + e^{-z}}, \quad \tanh z, \quad \operatorname{ReLU}(z) = \max(0, z), \quad \operatorname{GELU}(z) = z\,\Phi(z)
σ′=σ(1−σ)≤14,ReLU⁡′(z)=𝟏[z>0]\sigma' = \sigma(1-\sigma) \le \tfrac14, \qquad \operatorname{ReLU}'(z) = \mathbf 1[z > 0]

Why does it matter?

The switch from sigmoid to ReLU (around 2011) was one of the small calculus facts that made deep learning trainable.

The mathematics behind it

  • Derivatives of elementary functions★★★★★fundamental

    σ′=σ(1−σ)\sigma' = \sigma(1 - \sigma) and tanh⁡′=1−tanh⁡2\tanh' = 1 - \tanh^2: backprop reuses the forward value.

  • Exponential functions★★★★★frequent

    Sigmoid, softmax and tanh are all built from exe^x.

  • Continuity★★★★★fundamental

    Activations must be continuous (and almost everywhere differentiable) for gradient training to work.

  • Discontinuities★★★★★historical

    The perceptron's step activation is discontinuous; replacing it by the sigmoid made backpropagation possible.

  • ReLU has f−′(0)=0≠1=f+′(0)f'_-(0) = 0 \ne 1 = f'_+(0); frameworks simply pick a value (usually 0) at the kink.

  • Hyperbolic functions★★★★★frequent

    tanh⁡\tanh squashes to (−1,1)(-1,1) and its derivative 1−tanh⁡21 - \tanh^2 is cheap to compute from the output.

  • Domain and range★★★★★frequent

    The range of the sigmoid, (0,1)(0,1), is why its output can be read as a probability.

  • Limits at infinity★★★★★frequent

    The sigmoid saturates: as ∣x∣→∞|x| \to \infty its slope tends to 0, the root of vanishing gradients.

Where is it used?

Computing topics reachable from here, through the chain of ideas that leads to them:

What depends on it

This page has the essentials. A fuller treatment (intuition, formal definition, worked example) is on the way.

↑ ↓ to navigate · ↵ · Esc