Modern Activation Functions: GELU, SiLU, Mish, and Smooth Gating
Published:
Why ReLU Was Not the End of the Story
ReLU solved a huge optimization problem, but it also introduced a blunt shape:
- exactly zero on the negative side
- exactly linear on the positive side
- non-differentiable at zero
The Main Modern Idea
Instead of saying:
modern activations often say:
That makes them feel more like soft gates than hard thresholds.
Smooth ReLU-Like Families
ELU, SELU, and CELU
These functions keep the positive linear branch, but replace the dead negative side with a smooth saturating tail.
- ELU: negative values bend toward a negative plateau
- SELU: a self-normalizing variant designed to stabilize mean and variance
- CELU: a continuously differentiable ELU-like variant
They acknowledge that “all negatives become zero” is sometimes too crude.
GELU
GELU is the activation you now see everywhere in Transformers.
where \(\Phi(x)\) is the Gaussian cumulative distribution function: instead of passing all positive signals and rejecting all negative ones, GELU keeps a value in proportion to how likely it is to be useful under a Gaussian view of the input.
Step-by-step numerical comparison — GELU vs. ReLU vs. ELU at key input values:
| \(x\) | ReLU | ELU (\(\alpha=1\)) | GELU | \(\operatorname{GELU}'\) |
|---|---|---|---|---|
| −3 | 0 | −0.950 | −0.004 | 0.020 |
| −1 | 0 | −0.632 | −0.159 | 0.083 |
| 0 | 0 | 0 | 0 | 0.500 |
| 1 | 1 | 1 | 0.841 | 1.083 |
| 2 | 2 | 2 | 1.955 | 1.086 |
| 3 | 3 | 3 | 2.996 | 1.010 |
Notice how GELU preserves a small negative output near \(x=-1\) (−0.159), giving gradients a foothold even in the mildly negative region — something ReLU completely discards.
Swish and SiLU
Swish is the same family idea; SiLU is the common fixed version — smooth, slightly non-monotonic, and behaving like a gated linear response.
Mish
Mish pushes the same logic further:
It is smooth, non-monotonic, and often visually looks like “a softer Swish with a richer negative-side bend.”
Worked example — tracing a value through SiLU vs GELU vs Mish:
Let \(x = -0.5\) (a mildly negative pre-activation):
| Function | Computation | Output | Gradient at \(x = -0.5\) |
|---|---|---|---|
| ReLU | \(\max(0, -0.5)\) | 0 | 0 (dead!) |
| GELU | \(-0.5 \cdot \Phi(-0.5) \approx -0.5 \cdot 0.309\) | −0.154 | \(\approx 0.154\) |
| SiLU | \(-0.5 \cdot \sigma(-0.5) \approx -0.5 \cdot 0.378\) | −0.189 | \(\approx 0.072\) |
| Mish | \(-0.5 \cdot \tanh(\operatorname{softplus}(-0.5)) \approx -0.5 \cdot 0.393\) | −0.196 | \(\approx 0.065\) |
All three modern activations preserve a small but non-zero gradient where ReLU goes completely silent.
Fast Approximations and Mobile-Friendly Variants
Smooth functions are more expensive than piecewise-linear ones, which is why approximation-based activations became popular in efficient models:
- Hard Sigmoid: piecewise-linear approximation of sigmoid
- Hard Tanh: clipped tanh-like shape
- Hard Swish: approximation of Swish used in mobile models
A Few More Interesting Curves
The visual grid also includes a few less standard but conceptually useful shapes:
- Bent Identity: almost linear, but gently nonlinear near zero
- Arctan: another smooth bounded squash
- SELU / CELU: reminders that negative values do not have to be thrown away completely
Not default choices in modern LLMs, but reminders that activation design is about what happens around zero, in the tails, and in the derivative.
Which Ones Actually Matter Most Today?
| Activation | Why people use it | Main tradeoff |
|---|---|---|
| GELU | Very strong default in Transformers | More expensive than ReLU |
| SiLU / Swish | Smooth, gated, stable, often great in efficient deep nets | Still more expensive than ReLU |
| Mish | Flexible smooth non-monotonic response | Less standard in large production stacks |
| Hard Swish | Good hardware-friendly approximation | Less smooth than the original |
For general-purpose modern MLPs, ReLU is still a valid baseline, but SiLU is worth testing.
What Can Go Wrong with Modern Activations?
| Activation | Potential problem |
|---|---|
| ELU / SELU / CELU | More expensive than ReLU and more sensitive to architectural assumptions than many beginners expect. |
| GELU | Excellent in Transformers, but often unnecessary overhead in smaller or simpler models. |
| SiLU / Swish | Smoother optimization, but still costlier than piecewise-linear activations. |
| Mish | Can work well, but is less standardized and not always worth the extra complexity. |
| Hard approximations | Faster on-device, but they give up part of the smooth behavior that motivated the original function. |
Common Misunderstanding
The best activation is not the one with the fanciest formula. It is the one whose shape matches:
- the optimization constraints,
- the architecture,
- the hardware budget,
- the role of that layer inside the model.
References
- Hendrycks, D. and Gimpel, K. “Gaussian Error Linear Units (GELUs).” 2016.
- Ramachandran, P., Zoph, B., and Le, Q. V. “Searching for Activation Functions.” 2017.
- Misra, D. “Mish: A Self Regularized Non-Monotonic Activation Function.” 2019.
- Klambauer, G. et al. “Self-Normalizing Neural Networks.” NeurIPS 2017.
