Back to Deep Learning Mind Map
中文·English
🧠 Deep LearningID: activation-functions

Activation Functions

激活函数演进
🎯Core Definition
The evolution of activation functions is the main thread of nonlinearity in deep learning. Sigmoid squashes to (0,1)(0,1): σ(x)=11+ex\sigma(x)=\frac{1}{1+e^{-x}} with derivative σ(x)=σ(x)(1σ(x))=σ(1σ)\sigma'(x)=\sigma(x)(1-\sigma(x))=\sigma(1-\sigma), peaking at only 0.250.25 and saturating at both ends — under deep chain multiplication the gradient inevitably vanishes; Tanh is zero-centered with peak derivative 1 but still saturates. ReLU: ReLU(x)=max(0,x)\text{ReLU}(x)=\max(0,x) has a constant gradient of 1 on the positive side, fixing vanishing gradients, but zero gradient on the negative side causes Dead ReLU; LeakyReLU patches it with a 0.01x0.01x slope. GELU weights by the standard normal CDF Φ(x)\Phi(x): Φ(x)x+(1Φ(x))0.5x\Phi(x)x+(1-\Phi(x))0.5x (often approximated as xσ(1.702x)x\sigma(1.702x)), smooth with no hard cutoff — the default for BERT/GPT. SwiGLU brings gating into the FFN: xσ(xWg)(xWu)x\sigma(xW_g)\otimes(xW_u), used by LLaMA/Mistral and other modern LLMs to replace ReLU.
📌Overview
Comparison table — Sigmoid: range (0,1)(0,1), derivative peak 0.250.25, both-end saturation; Tanh: zero-centered, derivative peak 11, still saturates; ReLU: derivative 11 / 00, Dead ReLU; LeakyReLU: negative slope 0.010.01, mostly fixed; GELU: xΦ(x)x\Phi(x), smooth and differentiable everywhere; SwiGLU: xσ(xWg)(xWu)x\sigma(xW_g)\otimes(xW_u), gated product, stronger FFN expressivity.
💡Use Cases
interview classics — “why not Sigmoid in deep nets?”, “why GELU/SwiGLU in GPT?”; frequent asks include deriving σ=σ(1σ)\sigma'=\sigma(1-\sigma), comparing saturation ranges and derivative bounds, Dead ReLU causes and fixes, and the ReLU → GELU → SwiGLU motivation in FFN design.
Key Problems Solved
eliminates vanishing gradients and weak expressivity — Sigmoid's peak derivative 0.25 shrinks signals to about 0.25500.25^{50} over 50 layers, stalling training; ReLU's constant gradient of 1 lets gradients travel long distances; GELU/Swish smoothness improves optimization; SwiGLU gating is more expressive at equal parameter count — LLaMA reports lower perplexity and more stable training vs ReLU baselines.
🎯5 High-Frequency Exam Points
1
Derive σ(x)=σ(x)(1σ(x))\sigma'(x)=\sigma(x)(1-\sigma(x)) on the whiteboard; why do deep nets with Sigmoid inevitably suffer vanishing gradients (peak derivative 0.25)?
2
What does ReLU fix vs Sigmoid? Causes of Dead ReLU and its fixes (LeakyReLU, bias initialization)?
3
Write the GELU formula Φ(x)x+(1Φ(x))0.5x\Phi(x)x+(1-\Phi(x))0.5x with its properties; why do BERT/GPT use GELU over ReLU?
4
Gating mechanism of SwiGLU xσ(xWg)(xWu)x\sigma(xW_g)\otimes(xW_u); why do LLaMA/Mistral FFNs use SwiGLU?
5
Compare derivative ranges and saturation/death issues of Sigmoid/Tanh/ReLU/GELU; why are zero-centered outputs preferred?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Activation Functions"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Next CardVanishing/Exploding Gradients

🔗 More Deep Learning Knowledge Cards

Adam & AdamWAutograd Compute GraphBatch NormalizationClassic CNN Architectures