Chapter 9 — Quick Reference Notes
🔢 Parameter Counting Cheat Sheet
| Layer Type | Formula | Example (d=100, n=256) |
| FC (Dense) | nout × (nin + 1) | 256 × 101 = 25,856 |
| Conv2D | K × (Cin × F² + 1) | 16 × (3×3×3+1) = 448 |
| Vanilla RNN | n(d+n+1) + m(n+1) | varies |
| LSTM | 4n(n + d + 1) | 4×256×357 = 365,568 |
| GRU | 3n(n + d + 1) | 3×256×357 = 274,176 |
| Batch Norm | 2 × C | 2×256 = 512 |
| Pooling | 0 | 0 |
⚡ Activation Functions
| Function | Formula | Range | Derivative | Use In |
| Sigmoid | σ(x) = 1/(1+e−x) | (0,1) | σ(1−σ) | Binary output, gates |
| tanh | (ex−e−x)/(ex+e−x) | (−1,1) | 1−tanh² | RNN hidden states |
| ReLU | max(0, x) | [0, ∞) | 0 or 1 | Default for hidden layers |
| Leaky ReLU | max(αx, x) | (−∞, ∞) | α or 1 | When dying ReLU is an issue |
| GELU | x · Φ(x) | ≈(−0.17, ∞) | complex | Transformers (BERT, GPT) |
| Softmax | ezi/∑ezj | (0,1), sums to 1 | — | Multi-class output |
Quick Rule: Use ReLU for hidden layers, sigmoid for binary output, softmax for multi-class output.
🚀 Optimizer Quick Reference
| Optimizer | Adaptive? | Momentum? | Defaults |
| SGD | No | No | η = 0.01 |
| SGD + Momentum | No | Yes | β = 0.9 |
| AdaGrad | Yes | No | η = 0.01 |
| RMSProp | Yes | No | γ = 0.9, η = 0.001 |
| Adam | Yes | Yes | β1=0.9, β2=0.999, η=0.001 |
Mnemonic for Adam defaults: “9-triple9-thousandth” → β1=0.9, β2=0.999, η=0.001.
🏗 Architecture Quick Comparison
| Architecture | Best For | Key Feature | Sequential? |
| MLP | Tabular data | Fully connected | No |
| CNN | Images, spatial data | Weight sharing, local connectivity | No |
| RNN | Sequences | Hidden state recurrence | Yes |
| LSTM | Long sequences | Cell state + 3 gates | Yes |
| GRU | Long sequences (faster) | 2 gates, no cell state | Yes |
| Transformer | Everything (NLP, CV, …) | Self-attention, parallelisable | No |
⚠ Common GATE Mistakes
- Forgetting the +1 (bias) in parameter counting.
- Confusing floor vs ceiling in CNN output formula — always use floor.
- Thinking pooling has learnable parameters — it has zero.
- Applying dropout at test time — only used during training.
- Mixing up LSTM gates: forget gate erases; input gate writes.
- Forgetting bias correction in Adam (÷ by 1−βt).
- Ignoring the scaling factor √dk in attention.