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

FunctionFormulaRangeProsCons
LinearSimpleCannot learn non-linear patterns
SigmoidSmooth, probabilistic outputVanishing gradient for
TanhZero-centred, steeper than sigmoidVanishing gradient for
ReLUFast, avoids vanishing gradientDying ReLU (neurons output 0 permanently)
Leaky ReLUFixes dying ReLUSmall negative slope is a hyperparameter
Softmax, sums to 1Outputs probabilitiesUsed 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)