Projectabout 4 hours
Project: train a network end to end
After this project you can train, diagnose and improve an image classifier on Fashion-MNIST.
Project
Train, diagnose and improve a clothes classifier
You build a training script that teaches a network to tell ten kinds of clothes apart, checks itself before it trains, draws its two curves, closes the gap between them with the course's fixes, and then reads photos of your own clothes.
You build it in the starter, one step at a time. The finished project is there to read when you are stuck.
git clone https://github.com/FaydenAI/learn-deep-learning.git
cd learn-deep-learning/project/starter
uv syncGet the starterRead the finished project
Part 1
The pictures, and a baseline
Fashion-MNIST is 70,000 small grey pictures of clothes from Zalando's shop, in ten kinds: 60,000 to learn from and 10,000 for a test. You keep 10,000 of the 60,000 aside to watch after each epoch, leave the test set closed until part 4, and train a baseline that every later network has to beat.
UsesThe artificial neuronSoftmax and cross-entropyBackpropagationThe training loop
- Run the testsRun it
- Keep a validation set apartYour turn
- The loss at the startYour turn
- One epochYour turn
- Score what it does not learn fromYour turn
- The baselineRun it
When you have run it
After five epochs, what share of the 10,000 pictures kept aside does the baseline get right?
Part 2
Two networks, and their curves
Now the course's own network, sized for these pictures, and a small CNN, the family that slides one small window over every place of a picture. Before either trains, two checks from the course's lesson on loss curves: the loss at the start, and one batch memorized. Then each trains for 15 epochs, and you read its two curves.
UsesLayers and networksArchitecture familiesReading loss curvesThe training loop
- The course's network, for 28 by 28Your turn
- A network that slides windowsYour turn
- Memorize one batch firstYour turn
- Draw the two curvesYour turn
- Train both, and read their curvesRun it
When you have run it
In
curves-cnn.png, the training loss falls to the end. What does the validation loss do, and what does it mean?Part 3
Close the gap
The CNN is the better network, and it starts to memorize. Here you write the course's fixes, one step each: keep the best epoch and stop, switch numbers off with dropout, warm the rate up and then lower it, and save a checkpoint after each epoch, so a run that stops can go on where it was. Then one run with all of them.
UsesDropout, weight decay and early stoppingWarmup and learning-rate schedulesTraining on a GPUReading loss curves
- Keep the best epoch, and stopYour turn
- DropoutYour turn
- Warmup, then a cosineYour turn
- A checkpoint, and a run that goes onYour turn
- The improved runRun it
When you have run it
What share of the 10,000 pictures kept aside does the kept model get right?
Part 4
The test set, and your own clothes
The test set is opened once, now that every choice is made. Then the network reads photos of your own clothes. A network reads new pictures well only when they are made like the ones it learned from, as the course's lesson on transfer learning found. So you make your photos the way Fashion-MNIST's pictures were made, and look at what the network finds closest to each. This part is yours: `mine.py` holds only what goes in it.
UsesSoftmax and cross-entropyWhat hidden layers learnPretraining and transfer learning
- Open the test set, onceRun it
- Photograph your own clothesOn your own
- Make a photo look like the training picturesOn your own
- Read your photosOn your own
- The pictures it finds closestOn your own
- Run it on your photosRun it
When you have run it
On the test set, which two kinds does the network mix up most?
Run on Python 3.13, PyTorch 2.15.0, torchvision 0.29.2, matplotlib 3.11.2, Pillow 13.0.0, on a CPU. Checked on .
