Course 3 of 9

Calculus and Optimization for AI

After this course you can explain how a model learns by following gradients.

9 lessons, 3 labs and a project. About 1 h of video.

Start with lesson 1
  1. Functions and lossA model is a function with numbers it can change, and its loss is one number for how wrong those numbers make it.8 min
  2. The derivativeA derivative is the slope of the loss at one point, found by a tiny nudge: its sign says which way to turn a weight, and its size how much the loss changes when you turn it.6 min
  3. Partial derivatives and the gradientThe gradient is every weight's slope written as one arrow: it points the steepest way up the loss, and it is longer where the loss is steeper.6 min
  4. Gradient descent and the learning rateStep against the uphill arrow again and again, taking the largest share of it that still makes the loss fall steadily.9 min
  5. Lab 1Find the Gentoos' middle, by walking downhillYou will write the loss of one point among the Gentoos, find its slopes by a tiny nudge and by a formula, and walk it downhill to their middle at three learning rates.35 min
  6. The chain ruleWhen one thing moves the next, their rates multiply: the slope of a loss built from pieces is the rates of its pieces multiplied.7 min
  7. Loss landscapesFlat ground is not always the bottom: it can be a saddle with a way down, and a model with many weights nearly always has one.9 min
  8. Lab 2Get a two-layer line off the saddleYou will find the slopes of a two-layer line with the chain rule, see a walker stuck on the saddle, and get two walkers off it into different valleys.40 min
  9. Stochastic gradient descentTake many cheap steps, each on a few examples picked at random: their arrows are a little off, but right on average, and they get there sooner.7 min
  10. Momentum and AdamWhen one learning rate can't suit every weight, momentum lets steps that agree build up speed, and Adam gives each weight its own step size.7 min
  11. Lab 3Batches, momentum and Adam, written by handYou will deal the penguins into shuffled mini-batches and train on them, then write momentum and Adam yourself and race them down the long valley.45 min
  12. ReviewQuestions from the whole course8 questions from 8 lessons, in a mixed order. See what you still remember.
  13. EndingWhat can you build with calculus and optimization?Put gradient descent to work by training a line that predicts penguin weights. Start with NumPy, then use PyTorch and try your own data.1 min
  14. ProjectTeach a line the penguinsYou build a notebook that teaches a line to guess a penguin's mass from its flipper: the loss, its arrow and the steps written by hand in NumPy, then the same line with PyTorch's backward() and its optimizers, on batches and in a long valley, and last a line for a table of your own.2.5 h