AI Activation Functions Tutorial: Relu, Sigmoid, Tanh

TL;DRActivation functions add nonlinearity — ReLU, sigmoid, tanh — so networks learn complex patterns.

Without a nonlinear activation, stacked linear layers collapse into one linear layer. ReLU (max(0,x)) is the modern default — simple, fast, avoids vanishing gradients. Sigmoid (0-1) and tanh (-1 to 1) squash outputs but saturate and can vanish gradients in deep nets. Choosing the right activation per layer (ReLU hidden, sigmoid/softmax output) matters for training.

Key points

Common mistakes

Try it: Explain why stacked linear layers need a nonlinearity between them.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>ReLU(x) = max(0, x)   ← default hidden
sigmoid → 0..1, tanh → -1..1 (can vanish)
no activation → many layers = one linear layer</pre></body></html>
Open the interactive lesson →
Neural Networks · The Perceptron Origin Loss Functions · Mse · Cross-Entropy