DEEP LEARNING / 1. PERCEPTRON & ACTIVATIONS
Perceptron & Activation Functions
The building block — one neuron, then many
EXPLANATION
A single neuron computes a weighted sum of inputs, adds a bias, then passes it through an activation function. Without activation functions, stacking layers is useless — n linear layers = 1 linear layer. Activations introduce non-linearity, which is what gives neural networks their power to approximate any function. Key activation functions: • Sigmoid → squashes to (0,1), used in output for binary classification. Problem: vanishing gradients • Tanh → squashes to (-1,1), zero-centered. Still has vanishing gradient problem • ReLU → max(0,x). Simple, fast, no vanishing gradient. Problem: dying ReLU • Leaky ReLU → fixes dying ReLU with small slope for x<0 • GELU → used in transformers (BERT, GPT). Smooth approximation of ReLU
DATA FLOW
Single Neuron: x1 ──(w1)──┐ x2 ──(w2)──┼──→ z = w·x + b ──→ a = activation(z) ──→ output x3 ──(w3)──┘ Activation functions: Sigmoid: σ(z) = 1 / (1 + e^-z) → (0, 1) Tanh: tanh(z) = (e^z - e^-z)/(e^z + e^-z) → (-1, 1) ReLU: max(0, z) → [0, ∞) GELU: z · Φ(z) (Φ = normal CDF) → smooth
CODE