Activation functions
What it is
The nonlinearity between linear layers: ReLU, LeakyReLU, ELU, GELU, SiLU/Swish, Mish, and the gated GLU family.
When to use it
GELU in vision transformers, SwiGLU in modern LLMs (the feed-forward block's gating is where much capacity lives).
Caveats
No activation is best everywhere; the right choice depends on the architecture and its normalization. ReLU units can die (output zero permanently), sigmoid and tanh saturate and shrink gradients, and smoother functions cost a little more compute.
Key ideas
- Supply the nonlinearity; without them stacked layers collapse into one linear map
- ReLU is the cheap default; GELU and SiLU are smooth variants used in transformers
- Gated forms such as SwiGLU are now standard in LLM feed-forward blocks
Related architectures
Original paper
Gaussian Error Linear Units (GELUs) (2016, arXiv)
Lessons that cover it
- One Neuron, Many Inputs: The Dot Product
- Measuring Error: Choosing a Loss Function
- Which Way Is Downhill? Derivatives by Hand and by Nudging
- Let the Computer Do the Calculus: A Tiny Autograd Engine
- From Numbers to Arrays: Batches and Matrix Gradients
- Solving XOR: Why Networks Need a Hidden Layer
- Choosing Among Many: Classification with Softmax
- Starting Right: Initialization and Normalization
- Real Data: Reading Handwritten Digits
- After Training: Saving Models and Making Predictions
- Same Weights Everywhere: From Dense Layers to Convolutions
- Capstone: A Tiny Attention-Based Language Model
- Transformer Mathematics: Attention Scaling, RoPE & Latent Projections
- Scaled Dot-Product & Multi-Head Attention
- Mixture of Experts (MoE) & Multi-Head Latent Attention (MLA)