Step −5 −4 −3 −2 −1 0 1 2 3 4 5 −1.50 −1 −0.50 0 0.50 1 1.50 2 2.50 3 z output The first artificial neurons used a step: 1 if z is zero or more, 0 otherwise. For z = 1.50 the output is 1. Its derivative is zero everywhere, so it cannot be learned with gradients.
Sigmoid −5 −4 −3 −2 −1 0 1 2 3 4 5 −1.50 −1 −0.50 0 0.50 1 1.50 2 2.50 3 z output The red curve is the sigmoid: a soft step, between 0 and 1. For z = 1.50 it is 0.82. It reads like a probability.
tanh −5 −4 −3 −2 −1 0 1 2 3 4 5 −1.50 −1 −0.50 0 0.50 1 1.50 2 2.50 3 z output The blue curve is tanh: shaped like the sigmoid but between −1 and 1, symmetric around zero. For z = 1.50 it is 0.91.
ReLU −5 −4 −3 −2 −1 0 1 2 3 4 5 −1.50 −1 −0.50 0 0.50 1 1.50 2 2.50 3 z output The yellow curve is ReLU: 0 if z is negative, otherwise z itself. For z = 1.50 it is 1.50. It is the cheapest to compute and the most used in deep networks today.
One z, four outputs −5 −4 −3 −2 −1 0 1 2 3 4 5 −1.50 −1 −0.50 0 0.50 1 1.50 2 2.50 3 z output For z = 1.50: step 1, sigmoid 0.82, tanh 0.91, ReLU 1.50. Drag the vertical line to change z.
Derivatives −5 −4 −3 −2 −1 0 1 2 3 4 5 −1.50 −1 −0.50 0 0.50 1 1.50 2 2.50 3 z output Learning rests on derivatives. The sigmoid's derivative is at most 0.25 and falls to zero as z grows; here it is 0.15. ReLU's derivative is always 1 for positive z; here it is 1. That is why gradients vanish with sigmoids in deep networks, but not with ReLU.
Which one when −5 −4 −3 −2 −1 0 1 2 3 4 5 −1.50 −1 −0.50 0 0.50 1 1.50 2 2.50 3 z output Hidden layers mostly use ReLU or its variants. At the output the job decides: sigmoid for two classes, softmax for many, no activation for predicting a number.
Why it matters −5 −4 −3 −2 −1 0 1 2 3 4 5 −1.50 −1 −0.50 0 0.50 1 1.50 2 2.50 3 z output Without activations, however many layers a network had, it would equal a single linear function. Choosing the right activation can decide whether a network can be trained at all.