Tutorial · 1
Quickstart
One classifier, start to finish, in five blocks: make the data, look at it, build a model, train it, and find out what it got wrong. Everything runs here — press Run on each block in order, and edit anything you want to poke at.
1 · The data
Real datasets arrive as files; this one arrives as a function, so the tutorial cannot break on a download. Each sample is an 8×8 image containing either a vertical or a horizontal bar, with noise on top. The task is to say which.
2 · The model
Flatten the 8×8 image, two linear layers with a ReLU between them, two outputs —
one score per class. CrossEntropyLoss takes those raw scores, not
probabilities, exactly as it does in torch.
3 · Training
The loop is the one from lesson 4: zero the gradients, forward, loss, backward,
step — wrapped in a scope so the step's scratch buffers are released.
plot() collects the loss and the curve is drawn when the run finishes.
4 · How good is it?
On data it has never seen. A number measured on the training set answers a different, easier question — and this model is small enough that the difference is visible if you shrink the training batch above.
5 · What did it get wrong?
The most useful thing a classifier can show you is its mistakes. If they look obvious to you, the model is missing something learnable; if they look ambiguous to you too, the ceiling is in the data.
nn, so you can see what those layers are doing.