Neuron 101

A neural network from scratch / Activation functions

Türkçe

Plate44

Unit 5 · Topic 2 of 12

Activation functions

Easy, 7 min, 8 steps

−5−4−3−2−1012345−1.50−1−0.5000.5011.5022.503zoutput
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 8 Step

Step

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.

Open in Colab
  1. import math
  2. def adim(z):
  3. return 1 if z >= 0 else 0
  4. def sigmoid(z):
  5. return 1 / (1 + math.exp(-z))
  6. def relu(z):
  7. return max(0, z)
  8. z = 1.5
  9. print(adim(z), sigmoid(z),
  10. math.tanh(z), relu(z))
  11. s = sigmoid(z)
  12. print(s * (1 - s), 1 if z > 0 else 0)
z
1.50
adim
1
sigmoid
0.82
tanh
0.91
relu
1.50