Course 6 of 9

Deep Learning

After this course you can build, train and debug a neural network in PyTorch.

19 lessons, 7 labs and a project. About 2 h 5 min of video.

Start with lesson 1
  1. The artificial neuronA neuron multiplies each input by its own weight, adds them up with a bias, and bends the total: a sum you can work out by hand.8 min
  2. Layers and networksOne neuron draws one straight line; a layer of neurons draws several, and the next layer joins them into a shape, but only with a bend between the layers.7 min
  3. Softmax and cross-entropySoftmax turns a network's scores into chances by raising e to each score and dividing by the total, and the loss is the surprise at the right answer: about 2.30 for ten digits before any training.7 min
  4. Lab 1A digit reader, part by partYou will build the course's digits network one piece at a time, from a single neuron to its ten scores, turn the scores into chances and a loss by hand, and check its loss before it learns against a fair guess of 2.30.40 min
  5. BackpropagationThe network keeps every value on the way forward; one pass back from the loss multiplies the rates along each path and adds where paths meet, giving every weight its slope.9 min
  6. The training loopTraining repeats five lines on batch after batch, epoch after epoch: work out the scores and the loss, clear the old slopes, find the new ones, and step; and after each epoch, check pictures the network never learns from.6 min
  7. Lab 2Train the digit readerYou will check the slopes a backward pass gives against slopes found by nudging each weight, then write the training loop that takes the digits network to about 95 in 100 on the pictures kept aside, and train lesson 2's darts with it.40 min
  8. Vanishing gradients and residual connectionsOn the way back, every layer multiplies the slope again, so a deep network loses it; a skip connection gives the slope a path back that never shrinks.7 min
  9. Normalization layersWith skips, every block adds to the numbers, so they grow block by block; a norm rescales them before each block, so every block reads numbers of the same size.7 min
  10. Dropout, weight decay and early stoppingA network with more neurons than it needs learns its own pictures, mistakes included; stop at the best epoch, switch off random neurons while it trains, or shrink every weight a little at every step.7 min
  11. Lab 3A deep digit reader that doesn't memorizeYou will make the digits network twenty layers deep and still have it learn, with a skip round each layer and a norm before it, then keep a run with wrong labels from learning them by heart with dropout, weight decay and early stopping.45 min
  12. Reading loss curvesRead a run's two loss curves together, and make the network memorize one small batch before a long run: each way a run goes wrong leaves its own shape.7 min
  13. Training on a GPUTraining holds 16 bytes for every weight, plus values that grow with the batch: so choose the batch that fits, use bf16 to hold a big model in half the room, and save as you go.8 min
  14. Warmup and learning-rate schedulesChange the learning rate as training goes: raise it slowly at the start, so Adam's first steps stay small, and lower it towards 0 at the end, so the network can settle.7 min
  15. Lab 4A training run that checks itselfYou will write the checks a training run makes before it starts, use them and the curves to find what is wrong with three broken runs, then make one script that runs on a GPU or a CPU, stops and resumes from a checkpoint, and learns with warmup and a cosine decay.45 min
  16. Architecture familiesEach family of networks assumes something about its data, where to look for what matters, and that assumption helps when it is true and costs when it is false.7 min
  17. What hidden layers learnA hidden layer turns each input into a few numbers, a description the network learned for its task, in which inputs with the same answer land close together.6 min
  18. Lab 5Who reads a moved digitYou will train an MLP and a small CNN on the digits, move every picture one pixel to the right and see which still reads it, then look inside each one's hidden layer for what it keeps of a moved digit.40 min
  19. Self-supervised learningHide part of the data and train the network to fill it in: the answer comes from the data itself, so no one has to write a label.6 min
  20. Reinforcement learningAn agent learns from rewards by trying moves, mostly taking the best one so far and sometimes another, and passing each reward back to the moves that led to it.8 min
  21. Lab 6A tiny word maker, taught by rewardsYou will train a small network that writes words letter by letter, first on a list of real words with no labels written by anyone, then on rewards alone, and watch it learn a check you set, and game one.40 min
  22. Pretraining and transfer learningStart from a network already trained on millions of photos, give it a new last layer for your own kinds, and train only that layer when your photos are few, or all of it, gently, when you have more.6 min
  23. Loading pictures and augmentationChange each training photo at random every time it is read, in ways that keep its label, and give the network every photo at one size, prepared exactly as it was trained.7 min
  24. Autoencoders and latent spaceAn autoencoder squeezes each input into a few numbers and learns to draw it back, and those numbers make a space where alike inputs sit close.6 min
  25. Lab 7Digits from ten labels a kindYou will train an autoencoder on the digits with their labels put away, reuse its encoder to read digits from only ten labelled pictures of each, frozen and then fine-tuned, and hold both against a network trained from scratch on the same few.45 min
  26. ReviewQuestions from the whole course10 questions from 10 lessons, in a mixed order. See what you still remember.
  27. EndingWhat can you build with deep learning?The course's project: train a network to tell shirts, shoes and bags apart, read its two curves, then let it read photos of your own clothes.1 min
  28. ProjectTrain, diagnose and improve a clothes classifierYou 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.4 h