Activation Functions
Source: Unit 2 §9
Activation functions exist to inject non-linearity - without one, a layer is just linear regression and depth buys nothing. Different tasks want different activations, and the five below are the ones the course names.
Sigmoid
- It is monotonic - entirely non-decreasing.
- The output lies in , so it can be interpreted as a probability.
Tanh (hyperbolic tangent)
- It is monotonic.
- Negative inputs map strongly negative and zero maps to near zero, so the function is zero-centred - which often trains better than sigmoid.
ReLU (rectified linear unit)
- One of the most commonly used activations. It converts any negative input to 0.
- Cheap to compute and cheap to differentiate, which matters at every layer of a deep network.
A neuron whose inputs keep landing in the negative region always outputs 0 - and its gradient there is also 0, so no update can ever move it back. It has died and stops learning permanently.
Leaky ReLU
- Leaky ReLU is a variant of ReLU that solves the dying-ReLU problem by giving negatives a small slope rather than zero.
- can be a fixed small value, or a learnable parameter the network tunes for itself.
Softmax
- It is a generalisation of sigmoid, used in the final layer for multi-class classification.
- It gives the probability of each class, and the outputs sum to 1.
Worked example
Output-layer sums .
- Exponentiate each: , , , .
- Sum them: .
- Divide each exponential by the sum: .
- Check: the four values sum to 1. Class 4 is the most likely, with 87% of the mass.
Quick comparison
| Function | Range | Note |
|---|---|---|
Sigmoid 1/(1+e⁻ˣ) | (0, 1) | probability; binary output |
| Tanh | (−1, 1) | zero-centred |
ReLU max(0, x) | [0, ∞) | fast, common; can "die" |
Leaky ReLU (αx for x < 0) | (−∞, ∞) | fixes dying ReLU |
Softmax eˣⁱ/Σeˣʲ | (0, 1), sums to 1 | multi-class output layer |