internalsGet Pro

Machine Learning Engineering · Module 04

Calculus and optimization for machine learning

Lessons
11
Free
1
Reading
~3 h

Your progress

0 / 11 lessons done

Sign in to track

Lessons

  1. Derivatives: how outputs change with inputsEvery model you train learns by asking one question millions of times: if this weight moves a little, does the loss go up or down, and how fast? The derivative is the answer, and knowing how it is computed helps you debug training that won’t move or a gradient check that fails.13 min
  2. The chain rule: derivatives through layersA model is a chain of steps: a score, a squashing function, a loss, and in a network many layers in between. Every slope training uses is a product of the rates along that chain, and knowing that product explains slopes that vanish, losses that return infinity and models that won’t learn.14 min
  3. Gradients: derivatives with many inputsEvery training step of every model starts by computing one gradient: a slope for each weight, all from the same loss. Reading what it says, and what it doesn’t, helps you spot a wrong formula, a feature in the wrong units or a loss that grows with the dataset.14 min
  4. Gradient descent: walking downhill to a better modelFreeAlmost every model you train, from logistic regression to a neural network, finds its weights by gradient descent or a close variant. Knowing the loop, its stopping rule and what its loss curve looks like is how you tell a model that finished training from one that quietly gave up.14 min
  5. Learning rate: step size and stabilityThe learning rate is usually the first setting you tune and the most common reason a training run either never improves or ends in NaN. Knowing what sets its limit turns a guessing game into a short, predictable check.14 min
  6. Stochastic and mini-batch gradient descentAlmost every model you train in PyTorch learns from mini-batches, not the whole dataset. Batch size, shuffling and the learning rate decide whether training finishes in minutes or hours, and whether a jumpy loss curve is a bug or normal.17 min
  7. Momentum, Adam and modern optimizersAlmost every PyTorch training script picks an optimizer in one line, and that line decides how fast the model trains, which learning rate works and how much memory training needs. Knowing what SGD, momentum, Adam and AdamW do inside lets you choose one on purpose and debug it when the loss misbehaves.17 min
  8. Convex and non-convex problemsLinear and logistic regression give the same weights from any start; neural networks and k-means don’t. Knowing which of the two you have tells you whether one training run is the answer or just one sample of possible answers.16 min
  9. Lagrange multipliers: the best answer within limitsBudgets, quotas and caps are everywhere in ML work: vouchers to send, a limit on how large weights may grow, a cap on compute. Lagrange multipliers find the best answer inside such a limit and put a price on the limit itself, and the same idea sits inside L2 regularization and support vector machines.16 min
  10. Jacobians and Hessians: derivatives for whole layersEvery layer in a network passes a vector to the next, so every backward pass is a chain of Jacobians, and every learning-rate limit is set by a Hessian. Knowing which of these matrices you can afford to build, and which you must only multiply by, explains how training fits in memory and how to measure curvature on a real model.17 min
  11. Automatic differentiation: how PyTorch finds gradientsEvery PyTorch model you train gets its gradients from autograd. Knowing what it records, what it keeps in memory and when it adds instead of replacing is how you fix gradients that double, memory that grows every step and errors raised from inside backward().16 min

Practise with