Training on a 2D Toy Dataset
Everything comes together now. The training loop is exactly four steps, repeated over and over: forward pass (compute the network's output), loss (score how wrong it is), backward pass (compute how every weight contributed to that wrongness), update (nudge every weight opposite its gradient). That's it — that's the entire training loop, for this tiny network and for GPT-scale ones alike.
To make this non-trivial, the data below is arranged in an XOR pattern: points in the top-right and bottom-left quadrants belong to one class, points in the top-left and bottom-right belong to the other. No straight line can separate these two classes — you need a hidden layer's nonlinearity to solve it. This exact problem is famous in neural network history for exactly that reason.
Predict before you look
Before hitting Play: what shape do you think the final boundary needs to take to correctly separate all four quadrant clusters — and can a network with just 4 hidden neurons actually pull it off?
Hit Play and watch the shaded background — the network's prediction at every point in the plane — bend from a meaningless initial pattern into two blue and two amber regions that actually separate the dots by color. That shifting shape is gradient descent, visualized directly: every epoch nudges every weight a little, and a few hundred nudges later, the network has carved out a boundary no single straight line ever could.
The dataset itself isn't fixed either — click empty space on the grid to add your own point of either color, or click an existing point to remove it. Every change retrains the same network from scratch on whatever's on the board, so you can build a pattern of your own and watch this exact training loop try to solve it.
The complete training loop, including the hand-derived backward pass:
One last question before this course wraps up: what happens if the network has more than enough capacity to fit the data — including its noise?
Why can't a single straight line separate the XOR-pattern data in this lesson?