Eight networks, one building block
Every architecture on the infographic is the same atom, a weighted sum pushed through a nonlinearity, wired to suit a different kind of data. Each one was built to get past a specific wall its predecessor hit.
a = φ(Wx + b)
The family tree
Each arrow is labelled with the problem that forced the next design. Hover a network for its key traits, select it to open its lab.
What the wiring costs
Parameter counts for one layer of each kind at the sizes you choose. Bar length is on a log scale, so each step to the right is roughly ten times more weights.
1Perceptron
One weighted sum, one threshold. It draws a single straight line through the input space and calls one side 1 and the other side 0.
The problem it solves: learning a decision rule from examples instead of writing it by hand.
Experiments
- On AND, press Train until it stops and watch each mistake pull the line toward the misclassified point. Then try OR.
- Switch to XOR and train. Then drag the line and the arrow yourself: can any position get all four points right?
- Drag the line sideways, then rotate the arrow. Which move changes b, and which changes w?
2Multi-layer perceptron
Stack layers of perceptrons with a smooth nonlinearity between them, and the single straight line becomes a boundary that can bend.
The problem it solves: data a straight line can’t separate, like XOR.
Experiments
- Train on XOR with tanh, then hover each hidden tile. Each neuron draws one soft line; the output neuron combines them.
- Set Activation to None and train on Circles, even with 3 hidden layers. What shape is the boundary? This is Question 1 from the lesson, so try it before you answer.
- Try Spiral with 1 hidden layer of 3 units, then 3 layers of 8. Click to add points where the boundary looks wrong and watch it adapt.
3Convolutional network
Instead of one weight per pixel, slide one small kernel over the whole image. The same nine weights look for the same pattern everywhere.
The problem it solves: images make dense layers enormous, and a dense layer has no idea that neighbouring pixels belong together.
Experiments
- Press Play the scan and watch the window glide. Which patches give the strongest response to the Vertical edge kernel?
- Paint a horizontal stroke across the vertical bar and compare the four maps in the filter bank.
- Set stride to 2 and padding to 1. Watch the dashed padding cells appear and check the output size.
- Lesson trace reproduces the 4×4 example from Part 2. Hover each cell and read the products.
4Recurrent network
One cell reused at every time step, carrying a hidden state forward as a running summary of everything so far.
The problem it solves: sequences of any length, where order matters.
Experiments
- With Pulse, then silence, press Send gradient back and watch the red pulse shrink as it travels toward x₁.
- Raise Whh above 1.2 and send the gradient back again. Then try a negative Whh.
- Pick Lesson trace, play the forward pass, and check each step against Part 2.
5Long short-term memory
Adds a separate cell state that is edited rather than rewritten: forget a fraction, add new content, then reveal part of it.
The problem it solves: vanishing gradients, which make plain RNNs forget after a handful of steps.
Experiments
- On Pulse, then silence, send the gradient back and compare the bars with the dashed RNN line.
- Raise the forget gate’s b to 4 and watch the blue cell-state band stay thick. Then drop it to −2.
- Lesson trace reproduces Part 2: watch the f, i and o boxes fill, and check Ct = 1.5555 and ht = 0.6687.
6Gated recurrent unit
Merges the LSTM’s forget and input gates into one update gate, z, and drops the separate cell state.
The problem it solves: the LSTM’s cost. Three gate blocks instead of four, often with similar accuracy.
Experiments
- Set the update gate’s b to 3 so the cell mostly copies ht−1, then send the gradient back.
- Set the reset gate’s b to −4 so r ≈ 0. Which wire into the candidate h̃ goes dark?
- Lesson trace reproduces Part 2: ht = 0.6170.
7Autoencoder
Squeeze each input through a bottleneck, then rebuild it. Here the input is a 2-D point and the bottleneck is a single number: its position along a line.
The problem it solves: learning compact features without labels, and spotting inputs that don’t fit the pattern.
Experiments
- Drag a handle to rotate the latent line and watch the yellow dot ride the error curve. Then press Train.
- Click far along the line, then far to the side of it. Which test point gets flagged, and why does distance along the line cost nothing?
- Drag a few training points off the line and watch μ and the optimum shift. Then switch to Round blob.
8Transformer
Every token asks a question (its query), advertises what it holds (its key), and reads a weighted blend of everyone’s values. All tokens do this at the same time.
The problem it solves: RNNs process one step at a time and squeeze all history through one hidden vector.
Inside one block, in the correct order
The infographic stacks these boxes upside down and leaves out the position step. This lab focuses on the attention box.
Experiments
- With Position info off, hover each “the” and compare their arcs and rows. Then turn positions on.
- Turn off the √dk scaling and push Sharpness to ×4. Watch the softmax bars snap to one-hot and the entropies fall. Why would that hurt learning?
- Turn on the causal mask. Which arcs disappear, and why does the first token always attend to itself with weight 1?