From Perceptron to Differentiable MLP: Layers, Weights, and Activations
Agent-Assisted Engineering Check
Prerequisites
Day 33 autograd mastery check and the verified Value backward() semantics.
Learning Objective
Distinguish the historical perceptron (step activation) from a differentiable neuron $z = \sum_i w_i x_i + b$, $a = \sigma(z)$; explain why stacked layers with nonlinear activations are required for functions such as XOR; and state the exact structure of the reference 2-2-1 network used today.
Instructions
Read the concept decomposition below, then predict before computing.
A perceptron computes $z = \sum_i w_i x_i + b$ and fires $1$ if $z > 0$ else $0$. Its step activation makes the input-output map piecewise constant: the gradient is $0$ almost everywhere and undefined at the kink, so gradient-based training cannot improve it. A differentiable neuron replaces the step with a smooth activation such as $\tanh$.
A multilayer perceptron (MLP) stacks fully-connected layers: every neuron in layer $l$ consumes every activation in layer $l-1$. A single linear unit can only draw one straight decision boundary and cannot represent XOR; two or more layers with a nonlinear activation can.
Reference network N1 (used all day): inputs $x=(2.0, -1.0)$; hidden neuron $h_1$: weights $(0.5, -0.25)$, bias $0.1$, $\tanh$; hidden neuron $h_2$: weights $(-0.5, 1.0)$, bias $-0.2$, $\tanh$; output neuron $o$: weights $(1.0, -2.0)$, bias $0.3$, linear (no activation); loss $L = (o - y)^2$ with target $y = 1.0$.
Practice & Prediction Log
1. Before any computation, predict the signs of $z_1$ and $z_2$ and whether either hidden neuron is near saturation.
2. Count the trainable parameters of N1 and split them into weights and biases.
3. In one sentence, state why a step-activated perceptron cannot be trained by gradient descent.
4. Predict whether $o$ will be above or below the target $y = 1.0$.
Compute the weighted sums first: $z_1 = 0.5(2.0) + (-0.25)(-1.0) + 0.1$ and $z_2 = -0.5(2.0) + 1.0(-1.0) + (-0.2)$. For the parameter count, list every weight and every bias separately. For saturation, recall that $\tanh$ saturates for $|z| \gtrsim 4$.
Reference Solution:
1. $z_1 = 1.0 + 0.25 + 0.1 = 1.35$ (positive, mid-range, not saturated); $z_2 = -1.0 - 1.0 - 0.2 = -2.2$ (negative, also not deeply saturated).
2. Nine trainable parameters: six weights ($(w_{11}, w_{12}), (w_{21}, w_{22}), (w_{o1}, w_{o2})$) and three biases ($b_1, b_2, b_o$).
3. The step function is flat almost everywhere, so its derivative is $0$ wherever defined and undefined at $z = 0$; no useful gradient reaches the weights.
4. $o = 1.0 \cdot \tanh(1.35) + (-2.0) \cdot \tanh(-2.2) + 0.3 \approx 0.874 + 1.951 + 0.3 = 3.126$, well above $y = 1.0$.
The learner states the $z = \sum w_i x_i + b$ and $a = \sigma(z)$ equations, counts N1's nine parameters correctly, and explains in their own words why differentiability is required for gradient-based learning.
Authoritative Source Resources & Provenance
Neural Networks and Deep Learning: How the backpropagation algorithm works
Relevant Section / Range: Sections: Perceptrons, Sigmoid neurons, The architecture of neural networks
Verified Version & Date: Online book (Verified: 2026-10-30)
Clear four-equation derivation of backpropagation with scalar and matrix notation.
Matrix multiplication and the multivariable chain rule from Days 19-24.
All four backprop equations and derivations are self-contained within the lesson text.
Compared Candidate Sources & Selection Analysis (2)
Comprehensive graduate reference, but heavier tensor notation than needed for first MLP derivations.
Modular computational graph view; used as secondary source on Days 35-36.
micrograd: A tiny scalar-valued autograd engine
Relevant Section / Range: micrograd/engine.py: class Value (_backward closures and backward() topological sort); README 'Example usage'
Verified Version & Date: Git commit master (Verified: 2026-10-30)
Minimal, readable implementation of scalar autograd and MLP layers directly matched to our project.
Python object-oriented programming and operator overloading from Day 31.
The local projects/autograd engine is runnable offline and matches micrograd semantics.
Compared Candidate Sources & Selection Analysis (2)
Production scale, but too large and complex for tracing by hand in introductory lessons.
Vectorized autograd; micrograd's pure scalar model is pedagogical for hand backprop.