01 · 1986 · Stack neurons, bend the line

Multilayer perceptron

Put neurons in layers, with each layer reading the outputs of the one before it, and a straight line becomes a curve. Two layers can solve XOR, and enough neurons can trace almost any boundary. This is the classic “neural network playground”.

Train one below. Each neuron in the first hidden layer draws a line, the next layer combines those lines, and the coloured background shows what the whole network currently believes at every point.

How it works

  1. Forward. Each point flows through the layers. Every neuron takes a weighted sum, then applies a bend (the activation: tanh or ReLU). Without the bend, stacked layers would still only draw a line.
  2. Measure. Compare the output with the true colour. The gap, averaged over all points, is the loss.
  3. Backpropagate. Work out how much each weight contributed to the error, working backwards from the output (that is the next page).
  4. Update. Nudge every weight a little to reduce the loss (this uses the Adam optimiser). Repeat a few hundred times a second.

Try it

runs in your browser

Data

Hidden layers

Activation

Loss
—
Accuracy
—
Steps
0
Weights
0

Learning curve (loss: the lower it goes, the better the network fits)

line colour = weight sign · thickness = size

Things to try

The universal approximation idea

A network with even one hidden layer, given enough neurons, can approximate any smooth function. In practice depth is far more efficient than width, which is why modern models are “deep”.

Where MLPs are used

Spam and fraud scoring, recommendations, predicting machine failures, and the feed-forward blocks inside every transformer, where most of a large language model’s weights actually live.

Overfitting

Give a network too much freedom and it memorises the training points instead of learning the pattern. Real systems hold back unseen test data to catch this.