Activations and Gates Change the MLP
ReLU, GELU, and gated MLPs preserve the same outer interface while calculating different functions. Compare numerical outputs, derive a gated branch, and account for its additional projection.
The operation between the MLP projections is part of the architecture. ReLU, GELU, and gated variants can have the same input and output shapes while calculating different functions.
ReLU and GELU Treat Negative Inputs Differently
ReLU uses . GELU weights an input by the standard normal cumulative distribution:
For , exact GELU is approximately
whereas ReLU returns . GELU can retain a small negative value and smoothly changes near zero. An implementation should also state whether it uses exact GELU or an approximation.
A Gate Uses Two Expanded Projections
A gated MLP can be written as
where is coordinate-wise multiplication. One projection decides how strongly each expanded coordinate opens; the other supplies the value being gated.
If the gate preactivation is , the value branch is , and is ReLU, then
SwiGLU uses the SiLU activation in the gate and is one member of this broader family. Names alone are not enough: record the activation and every projection shape.
Compare Under a Parameter Budget
A gated MLP has an additional input projection. Keeping the same therefore increases parameters and computation relative to a two-projection MLP. Fair comparisons often reduce the gated hidden width, but the exact ratio depends on biases and conventions. State the actual shapes instead of relying on “same size.”
Q1. Calculate a gated coordinate
A ReLU gate receives and its value branch receives . What value reaches the down projection at that coordinate?
Compute it first, then check your number.
Hint
Solution
References
- Dan Hendrycks and Kevin Gimpel, Gaussian Error Linear Units (GELUs), 2016.
- Noam Shazeer, GLU Variants Improve Transformer, 2020.