activations -- GELU (erf / tanh) vs SiLU/Swish vs Mish
Between the multiplying steps of a layer sits a small bend: a function that takes each number on its own and passes it through a curve. Without it the whole stack collapses, because multiplying by one grid of numbers and then by another is the same as multiplying by a single combined grid, so a hundred layers would be worth exactly one. The curves actually in use are all much the same shape — near zero for negative inputs, near unchanged for large positive ones, with a shallow dip in between — and that is the honest finding here: which of them you pick makes very little difference.
Interactive page: the smooth activation functions used in transformer MLPs, plotted side by side. Anchor: A7 activation in MLP (Family C3).
What it shows
Four activations on one axis:
- GELU (erf, exact) —
0.5·x·(1 + erf(x/√2)). - GELU (tanh approx) —
0.5·x·(1 + tanh(√(2/π)·(x + 0.044715·x³))); the cheaper form most GGUF/llama.cpp models use (gelu_pytorch_tanh). - SiLU / Swish —
x·σ(x); the gate in SwiGLU. - Mish —
x·tanh(softplus(x)).
All four are smooth, non-monotonic (a small negative dip), ≈ x for large positive x and ≈ 0 for large negative x — which is why they're nearly interchangeable. Drag the x-marker horizontally (or hover the plot) to read all four values at a point you control — a vertical guide + a dot on each curve + a value tooltip track the cursor; on load the marker sweeps on its own freezes the moment you grab it. Scrub the transport to highlight each (its curve bolds and its formula shows); toggle zoom near 0, because the differences only show up around the dip (GELU's is shallowest ≈ −0.17, Mish's deepest ≈ −0.31).
Render tier
T1 (Canvas2D line plot + axes).
Wiring
layout.mount({animate:true, onPointer}) + a zoom toggle + a per-activation Transport, drawn with ctx and tensor.silu/gelu (Mish computed inline). The x-marker is dragged via onPointer (horizontal) and read back through the pixel↔x map captured in draw; the ambient sweep uses api.t and freezes on drag/hover. Headless hooks: ?x=VALUE (set marker x, freeze sweep), ?hover=x,y (fake cursor for the tooltip + guide), plus the existing ?step=N/?play=1/ ?zoom. Source: page.js.