Output, Gated, and Special Activations: Softmax, GLU, SIREN, and More
14 minute read
Published:
TL;DR: Many important activations are not โhidden-layer curvesโ at all. Softmax and sigmoid control outputs, GLU-style activations learn gates, shrinkage activations push values toward zero, and specialized activations such as SIREN or Gaussian RBFs are built for niche but powerful settings.
Output Activations Have a Different Job
Intuition First: In hidden layers, activations shape what the network thinks. At the output layer, activations shape what the network says. They must convert raw scores (logits) into the exact format the loss function expects. Using the wrong output activation is not just suboptimal โ it breaks the loss's mathematical assumptions and can make training completely undefined.
In hidden layers, activation functions mainly shape representation learning and gradient flow. At the output layer, they must match the task.
The three most important output cases
Task
Typical activation
Why
Binary classification
Sigmoid
Turns one logit into a probability in [0, 1]
Multi-class classification
Softmax
Converts logits into a probability distribution that sums to 1
Say a 3-class classifier produces logits z = [2.0, 1.0, 0.1].
Step
Computation
Result
Exponentiate
eยฒ, eยน, e^0.1
7.389, 2.718, 1.105
Sum
7.389 + 2.718 + 1.105
11.212
Normalize
7.389/11.212, 2.718/11.212, 1.105/11.212
0.659, 0.242, 0.099
Check
0.659 + 0.242 + 0.099
= 1.000 โ
The original logit differences (2.0 vs 1.0 vs 0.1) are now calibrated probabilities summing to 1. Note that a 1-unit logit advantage roughly triples the probability โ the exponential makes the winner-take-most effect strong.
Key Insight โ temperature: Dividing logits by a temperature T before softmax controls sharpness. Tโ0 makes softmax behave like argmax (one-hot). Tโโ makes it uniform. This is why temperature scaling is the standard post-hoc calibration technique: the model's weights stay frozen, only the output distribution is reshaped.
The same logits [2.0, 1.0, 0.1] passed through softmax at three temperatures. Low T (left) collapses probability onto the top class โ useful for greedy decoding. High T (right) spreads probability more evenly โ useful for knowledge distillation. T=1 is the standard training setting.
Why Gated Activations Became So Important
Intuition First: A classic activation like ReLU asks one question of each neuron: "should this value pass?" A gated activation asks two neurons to collaborate: one produces content, the other produces a gate score. The gate modulates how much of the content flows forward. This is conceptually identical to the gating mechanism in LSTMs and GRUs โ the same idea, applied at every feed-forward layer. It is why gated variants consistently outperform plain ReLU in large Transformer models.
Modern architectures often do not use a single scalar curve after an affine transform. Instead, they split the channel dimension and let one part gate another.
That gives you:
GLU: one linear branch gates another
SwiGLU: same idea, but with a SiLU/Swish-style gate
GeGLU: GELU gate
ReGLU: ReLU gate
GLU \[ \operatorname{GLU}(x) = a \otimes \sigma(b) \]
SwiGLU \[ \operatorname{SwiGLU}(x) = a \otimes \operatorname{SiLU}(b) \]
GeGLU / ReGLU \[ \operatorname{GeGLU}(x) = a \otimes \operatorname{GELU}(b), \qquad \operatorname{ReGLU}(x) = a \otimes \operatorname{ReLU}(b) \]
This family matters because large Transformers often rely more on gated feed-forward blocks than on plain ReLU-style MLPs.
<div class=โinsight-boxโ> Useful mental model: ReLU asks โshould this neuron pass?โ GLU-like activations ask โhow strongly should this feature gate another feature?โ </div>
Worked example โ GLU vs. plain linear, step by step:
Suppose an input vector is split into two halves: a = [1.2, โ0.4, 0.8] (content) and b = [2.1, โ1.5, 0.3] (gate input).
Step
GLU
Plain linear (no gate)
Compute gate
ฯ(b) = [0.89, 0.18, 0.57]
โ
Element-wise product
a โ ฯ(b) = [1.07, โ0.07, 0.46]
a = [1.2, โ0.4, 0.8]
Effect
The โ0.4 signal is suppressed to โ0.07 by a low gate value
โ0.4 passes through unchanged
The gate learned that the second feature is unreliable (low ฯ(b)=0.18) and almost entirely suppressed it. Plain linear cannot make this context-dependent decision.
<div style=โbackground:#fff7ed;border-left:4px solid #f97316;border-radius:8px;padding:.95rem 1.1rem;margin:1.25rem 0;โ>Key Insight โ SwiGLU in LLaMA/GPT-4 style FFN blocks: SwiGLU(x) = (Wโx) โ SiLU(Wโx). Compared to a standard two-layer MLP with a single activation, SwiGLU uses three weight matrices (Wโ, Wโ, Wโ for the final projection) but achieves better perplexity at the same parameter budget. The reason is expressivity: the gate is a full learned linear transformation, not just a fixed nonlinearity applied to the same pre-activation. This is why nearly every modern open-source LLM (LLaMA, Mistral, Gemma) uses SwiGLU in its feed-forward blocks instead of plain GELU-MLP.</div>
Figure 1 โ Not all activations play the same role. Hidden-layer activations shape features, output activations shape the prediction object, and gated activations decide how one feature stream modulates another.
Shrinkage and Sparse Activations
Intuition First: Standard activations pass strong signals and block weak ones. Shrinkage activations go further: they push small values all the way to zero, creating genuine sparsity in the representation. Think of it as denoising โ treat small activations as noise and eliminate them, keep only the confidently large values. Sparsemax takes this idea to the output layer: unlike softmax which distributes probability mass everywhere, Sparsemax assigns exact zero probability to unlikely classes, producing a sparse probability vector. This is especially valuable for attention mechanisms and structured prediction.
Another family is built around sparsity or denoising:
TanhShrink: returns x - tanh(x)
SoftShrink: softly pushes small values toward zero
HardShrink: zeroes small values completely
Sparsemax: like softmax, but can produce exact zeros
Entmax: interpolates between dense softmax and sparse alternatives
TanhShrink \[ \operatorname{TanhShrink}(x) = x - \tanh(x) \]
SoftShrink \[ \operatorname{SoftShrink}(x) = \begin{cases} x - \lambda, & x > \lambda \\ 0, & |x| \le \lambda \\ x + \lambda, & x < -\lambda \end{cases} \]
These are useful when you want more structured or selective outputs rather than dense probability mass everywhere.
Concrete example โ SoftShrink vs HardShrink vs Sparsemax (ฮป=0.5):
Input value
SoftShrink (ฮป=0.5)
HardShrink (ฮป=0.5)
Notes
2.0
1.5
2.0
Large value: both pass through
0.8
0.3
0.8
SoftShrink reduces, HardShrink passes
0.4
0.0
0.0
Both zero โ below threshold
0.1
0.0
0.0
Both zero โ below threshold
โ0.6
โ0.1
โ0.6
SoftShrink clips toward zero
โ1.5
โ1.0
โ1.5
Large negative: both pass
SoftShrink always shrinks by ฮป before zeroing; HardShrink either passes completely or zeros. SoftShrink is the classical wavelet/signal denoising shrinkage โ it corresponds to solving a LASSO-style proximal operator.
Same logits [3, 1, 0, โ1, โ2] through Softmax (left) vs. Sparsemax (right). Softmax distributes probability everywhere โ even irrelevant classes C4, C5 receive 5โ6%. Sparsemax projects onto the probability simplex using a thresholding operation, producing exact zeros for low-scoring classes. This is critical for sparse attention mechanisms where you want some tokens to receive literally zero weight.
Special-Purpose Activations
Some activations are not mainstream in basic classifiers, but they are extremely important in the right niche.
Maxout: takes the maximum over several learned affine responses
Sin / SIREN: uses sinusoidal activations for implicit neural representations
Gaussian / RBF: activates by distance from a center
Soft Exponential: learns whether to behave more like a log, linear, or exponential function
KAN / spline activations: learns the activation shape itself rather than choosing a fixed closed-form function
These remind us that โactivation functionโ is a much broader design space than just ReLU vs GELU.
<div style=โbackground:#fff7ed;border-left:4px solid #f97316;border-radius:8px;padding:.95rem 1.1rem;margin:1.25rem 0;โ>Key Insight โ why SIREN works for implicit representations: Modeling a continuous signal (image, shape, audio) as a neural function f(x,y)โRGB requires the network to represent fine-grained detail. ReLU-based networks produce piecewise-linear outputs โ they cannot represent smooth higher-order derivatives. SIREN uses sin(ฯx), whose derivatives are also sinusoids, so the network naturally represents smooth periodic structure at every layer. The frequency ฯ controls the scale of detail captured. SIREN networks have been shown to exactly fit high-resolution images with far fewer parameters than ReLU networks because every layer contributes smoothly to all derivative orders โ not just the zeroth.</div>
<div class=โblog-figureโ>
<svg xmlns=โhttp://www.w3.org/2000/svgโ viewBox=โ0 0 520 175โ style=โmax-width:520px;width:100%โ><rect x=โ1โ y=โ1โ width=โ518โ height=โ173โ rx=โ9โ fill=โ#f8fafcโ stroke=โ#dbe7f5โ/> <text x=โ260โ y=โ17โ text-anchor=โmiddleโ class=โsi-ttlโ fill=โ#0f2a36โ>SIREN sin(ฯx) vs. ReLU piecewise approximation</text> <line x1=โ30โ y1=โ100โ x2=โ500โ y2=โ100โ class=โsi-axโ/> <line x1=โ30โ y1=โ20โ x2=โ30โ y2=โ145โ class=โsi-axโ/> <text x=โ30โ y=โ158โ text-anchor=โmiddleโ class=โsi-lblโ>0</text> <text x=โ147โ y=โ158โ text-anchor=โmiddleโ class=โsi-lblโ>ฯ</text> <text x=โ264โ y=โ158โ text-anchor=โmiddleโ class=โsi-lblโ>2ฯ</text> <text x=โ381โ y=โ158โ text-anchor=โmiddleโ class=โsi-lblโ>3ฯ</text> <text x=โ498โ y=โ158โ text-anchor=โmiddleโ class=โsi-lblโ>4ฯ</text> <path d=โM30,100 C50,100 60,30 87,30 S120,100 147,100 C165,100 175,170 200,170 S235,100 264,100 C282,100 292,30 317,30 S350,100 381,100 C399,100 409,170 434,170 S469,100 498,100โ class=โsi-sinโ/> <path d=โM30,100 L57,100 L57,30 L114,30 L114,100 L171,100 L171,170 L228,170 L228,100 L264,100 L264,30 L321,30 L321,100 L381,100 L381,170 L435,170 L435,100 L498,100โ class=โsi-reluโ/> <line x1=โ40โ y1=โ168โ x2=โ65โ y2=โ168โ stroke=โ#0891b2โ stroke-width=โ2.4โ/> <text x=โ70โ y=โ172โ class=โsi-legโ fill=โ#0891b2โ>SIREN sin(ฯx) โ smooth all derivatives</text> <line x1=โ280โ y1=โ168โ x2=โ305โ y2=โ168โ stroke=โ#94a3b8โ stroke-width=โ2โ/> <text x=โ310โ y=โ172โ class=โsi-legโ fill=โ#94a3b8โ>ReLU approx โ piecewise, no smooth derivatives</text> </svg>SIREN (blue, smooth) vs. a ReLU piecewise approximation of the same sinusoidal target. The SIREN represents the true smooth signal exactly because its activations have infinite-order smooth derivatives. ReLU can approximate it, but only with many more layers and with derivative discontinuities that limit precision in applications like physics-based neural fields.
</div>
Figure 2 โ This last family is much more diverse. Some activations map logits to probabilities, some implement feature gating, some encourage sparsity, and some are designed for special function classes such as implicit fields or spline-based networks.
Common Mistakes
Four mistakes that show up constantly:
Applying softmax before `CrossEntropyLoss` in PyTorch. That loss expects raw logits.
Using sigmoid for mutually exclusive multi-class classification. Usually you want softmax instead.
Ignoring the output activation entirely. The last-layer activation should match both the task and the loss.
Assuming all gating activations are interchangeable. SwiGLU, GeGLU, and ReGLU can change optimization noticeably in large models.
Practical Recommendation Map
Use case
Recommended activation
Binary classification output
Sigmoid
Multi-class classification output
Softmax
Regression output
Linear
Transformer feed-forward blocks
GELU or SwiGLU
Sparse probability-like outputs
Sparsemax or Entmax
Implicit neural representations
SIREN
Radial similarity models
Gaussian / RBF
What Can Go Wrong with Output and Special Activations?
Activation family
Potential problem
Softmax
Easy to misuse with the wrong loss pipeline, especially if you apply it before losses that expect raw logits.
Sigmoid outputs
Wrong choice for mutually exclusive multi-class prediction, where softmax is usually the right tool.
GLU-style gating
More expressive, but also more parameter-heavy and architecture-dependent.
Sparsemax / Entmax
Useful for sparsity, but can change optimization behavior enough that they are not just drop-in replacements for softmax.
SIREN / RBF / spline-style activations
Very powerful in the right niche, but usually a poor default if the model and task were not designed for them.
Final Takeaway
Activation functions are not a side detail. They define:
how information flows forward,
how gradients flow backward,
what geometry the model can represent,
and what kind of output object the network produces.
That is why the full story needs more than one chapter. ReLU, GELU, Softmax, SwiGLU, Sparsemax, and SIREN are not solving the same problem. They all live under the same name, but they serve very different roles.
References
Dauphin, Y. N. et al. โLanguage Modeling with Gated Convolutional Networks.โ 2017.
Shazeer, N. โGLU Variants Improve Transformer.โ 2020.
Martins, A. and Astudillo, R. โFrom Softmax to Sparsemax.โ ICML 2016.
Peters, B. et al. โSparse Sequence-to-Sequence Models.โ ACL 2019.
Sitzmann, V. et al. โImplicit Neural Representations with Periodic Activation Functions.โ NeurIPS 2020.
Once ReLU became the default, researchers started asking a better question: can we keep the easy optimization while making the activation smoother, softer, and more expressive? This chapter covers the modern answers.
Activation functions are the reason neural networks can model curved decision boundaries instead of collapsing into one giant linear map. This chapter builds the intuition first, then walks through the classical functions that shaped deep learning.
FoPE rethinks long-context positional encoding from a frequency-domain perspective. Instead of only stretching RoPE heuristically, it explicitly improves attentionโs periodic extension so Transformers generalize more gracefully to longer sequences.
Position Interpolation rescales positions before applying RoPE so a model trained on short contexts can be adapted to longer ones with surprisingly little fine-tuning. It became the reference baseline for long-context RoPE extension.