The nonlinear step
Chapter 3 passed a linear model through the sigmoid to get a probability. A neural network does the same at every neuron. It computes the weighted sum, then runs it through an activation function before handing it on. Because that step bends the numbers, stacking layers can build up shapes no single line can make.
| Activation | Formula | Output |
|---|---|---|
| Sigmoid | 1 / (1 + e−x) | 0 to 1 |
| tanh | tanh(x) | −1 to 1, steeper |
| ReLU | max(0, x) | 0 for negatives, x otherwise |
ReLU, the rectified linear unit, is the usual first choice. It's cheap to compute, and its gradient doesn't shrink toward zero the way the S-shapes do at their flat ends, which matters once networks get deep. Any function can serve as an activation, and different layers can use different ones.
Switch the activation on the board and the network retrains. Linear gives a flat slope, and the other three bend the map, each in its own way. A network is just neurons in layers, weights and biases between them, and an activation on each neuron.
Neural networks aren't always better than a well-chosen feature cross. They're a flexible alternative when you can't guess the cross.