Activation Functions
Related: 4. Deep Learning and FCNs | 6. Loss Functions and Backpropagation | 8. Convolutional Neural Networks | Artificial Intelligence
Why Activation Functions?
Without non-linearity, no matter how many layers, the entire network collapses to a single linear function. Activation functions:
- Allow backpropagation (derivative is related to input)
- Enable stacking of multiple layers (non-linear combination)
Activation Functions Summary
| Function | Formula | Range | Pros | Cons |
|---|---|---|---|---|
| Linear | Simple | Cannot learn non-linear patterns | ||
| Sigmoid | Smooth, probabilistic output | Vanishing gradient for | ||
| Tanh | Zero-centred, steeper than sigmoid | Vanishing gradient for | ||
| ReLU | Fast, avoids vanishing gradient | Dying ReLU (neurons output 0 permanently) | ||
| Leaky ReLU | Fixes dying ReLU | Small negative slope is a hyperparameter | ||
| Softmax | , sums to 1 | Outputs probabilities | Used only in output layer for multi-class |
When to Use Which
- Hidden layers: ReLU (default), Leaky ReLU if dying neurons are an issue
- Binary classification output: Sigmoid
- Multi-class classification output: Softmax
- Regression output: Linear (no activation)