← Study Lab
Module 3updated 2026-07-04

The neuron & backprop

A neuron is a dot product, a bias, and a bend. Stack a few and the network can carve shapes a straight line never could — that's the universal-approximation idea, and you can watch bent neurons add up into any curve. Training is two passes: push data forward to a loss, then walk the chain rule backward to hand every weight its gradient. Follow that gradient node-by-node through a live computation graph, then train a 2-D net and watch its boundary curl into a ring.

We now have every piece: a model is knobs (Module 0), the arithmetic is matmul (Module 1), and the loss is a negative log-likelihood (Module 2). This chapter wires those pieces into the object that started the revolution — the neural network — and shows the single algorithm that trains it: backpropagation. It is nothing more than the chain rule from calculus, applied with careful bookkeeping, at scale. Understand one neuron and one backward pass, and the rest is repetition.

The whole chapter in four lines1. A neuron is a weighted sum plus a bias, bent by a non-linear activation.
2. Stacking bent neurons can approximate any function — depth buys shape.
3. The forward pass runs data through the layers to a prediction and a loss.
4. Backprop walks the chain rule backward, handing every weight its gradient — then we step downhill.

3.1 One neuron: sum, bias, bend

A single neuron takes a vector of inputs, multiplies each by a weight, adds them with a bias, and passes the result through a non-linear activation. The weighted sum alone is just the dot product from Module 1 — a straight line. The activation is the crucial twist: without it, stacking layers collapses back into one linear map, and the network can only ever draw a flat hyperplane.

a=φ(Σiwixi+b)

w the weights — one knob per inputb the bias — shift the whole sumφ the activation — the bend (tanh, ReLU, sigmoid)

Three bends dominate. Sigmoid squashes to (0, 1) — a soft on/off switch, handy as a probability. tanh is its zero-centered cousin, squashing to (−1, 1).ReLUmax(0, z) — simply clips negatives to zero; it is nearly free to compute, doesn't saturate for positive inputs, and is the modern default in hidden layers. Grab the weight and bias below and watch a straight pre-activation line get bent by each. The weight sets steepness; the bias slides the bend left or right:

viz 1 one neuron: a = φ(w·x + b) — the sum is a line, φ is the bend
w1.4
b0.0

3.2 Why depth buys shape: universal approximation

Stack many neurons that all read the same inputs and you have a layer — every neuron's weighted sum computed at once is one matrix multiply. Feed a layer's outputs into another and you have a network: input → hidden → output. The hidden layer is where the power lives, and there's a theorem behind it: the universal approximation theorem says a single hidden layer with enough bent neurons can approximate any continuous function to any accuracy. The intuition is visual — each hidden neuron contributes one bend, and the output layer adds the bends up. Enough bends, placed and scaled right, trace any wiggle.

Watch it happen. The faint curve is a target function; the bold curve is a 1 → H → 1 tanh network trying to match it. Press fit and gradient descent tunes the bends; raiseH and the network gains the capacity to trace finer detail. Too few neurons and it can only manage a crude sketch — not enough bends to go around.

viz 2 H bent neurons, added up, can trace any curve
H8
step0
MSE
Why the hidden layer earns its keepA network with no hidden layer is just logistic regression — it can only split the plane with a single straight line. Data that lives inside a circle cannot be separated that way at all. The hidden layer's bent neurons let the boundary curve. In viz 4 you can switch the hidden layer off and watch the exact failure: a straight cut through data that needs a loop.

3.3 The forward pass, then backprop — follow the gradient

Forward: push inputs through the layers to a prediction, then score it against the truth with a loss. Backward: we need to know how nudging each weight would change the loss — the gradient ∂L/∂w. Backprop computes all of them in one sweep by applying thechain rule from the loss back to the inputs, and its trick is reuse: each node multiplies the gradient arriving from its right (the "upstream" gradient) by its own localderivative, then passes the product left. Nothing is recomputed.

∂L/∂w=∂L/∂a·∂a/∂z·∂z/∂w

Below is a real computation graph for one neuron scoring one example:p = w·x, z = p + b, a = tanh(z), and lossL = (a − t)². Each node shows its forward value on top. Pressbackward pass and watch the gradient flow right-to-left — the caption shows the exact local-derivative multiply at each hop. Then drag w orb, or press gradient step, and watch L fall as the weights move against their gradients.

viz 3 backprop = the chain rule on a graph · forward value / gradient ∂L/∂·
press “backward pass” to send the gradient back through the chain rule
loss L
∂L/∂w
∂L/∂b

That is the entire algorithm. A real network is this same graph with millions of nodes; the backward pass visits each once, multiplying upstream gradient by local derivative. Take one step downhill —w ← w − η·∂L/∂w with learning rate η, exactly the ball-roll of Module 0 — and repeat.

3.4 The whole loop, live: bending a boundary

Now the full thing on 2-D data. The plot is the network's mind: each pixel is colored by the class it predicts, teal vs amber, with a pale band at the undecided boundary. The dots are real data — a ring of one class around a core of the other. Press trainand every frame runs forward-and-backward over all points and steps the weights. RaiseH for more bends; push η too high and training thrashes. Then flip hidden layer → off and watch a single straight line fail to wrap a circle.

press ▶ train — watch the boundary curl to enclose the ring
epoch0
loss (BCE)
accuracy
parameters

With the hidden layer gone the model is a single straight line, and a straight line simply cannot wrap a circle — the accuracy stalls near 50% no matter how long you train. That failure is the whole reason depth exists, and the reason every network from here on is many layers deep.

▸ how this connects to the endgame

Every training step you just watched is two matmul-heavy passes — forward to the loss, backward for the gradients — and the backward pass costs roughly twice the arithmetic of the forward one. A real training run is this exact loop, scaled to billions of weights and repeated for months on thousands of GPUs. The forward and backward passes are where nearly all the FLOPs live.

So when a GPU reports it is "busy" during training, it is supposedly grinding through these two passes. But the backward pass is memory-hungry — it must stash and reread every layer's activations — and that is precisely where lanes stall waiting on memory while nvidia-smi still reads 100%. To tell a real gradient step from a stalled one, you have to see inside forward-and-backward and measure the arithmetic that actually moved a weight. That is the layer Plasmient builds.

Go deeper — the original sources

We teach it in our own words and build the demo ourselves. To go to the source, these are the lectures and texts this chapter draws on — linked, not rehosted.