Skip to content

Track T34

Math for Machine Learning

Distances, matrices, gradients and optimizers: the math every model runs on.

Unit 1Geometry of data

· 2 lessons
  1. 1Rows as points: vectors and distancesTreat each row of a table as a point in space, measure how far apart two rows are in four different ways, and see why the choice of distance changes every method built on it.Introductory · 11 min
  2. 2Units decide the answer: scaling and neighborsA column measured in thousands drowns out one measured in tenths. See how standardizing changes nearest neighbors and principal components, and where the scaling must be fitted.Introductory · 12 min

Unit 2Matrices

· 4 lessons
  1. 3Matrices as maps, and what rank countsA data table is a matrix, and a matrix is also a machine that moves vectors. Read a matrix-vector product two ways, build the covariance matrix from the data, and count independent directions with rank.Applied · 12 min
  2. 4Eigenvectors: the directions a matrix only stretchesFind the directions a covariance matrix stretches without turning, see that they are the principal components, and compute the first one with nothing but repeated multiplication.Applied · 13 min
  3. 5The SVD and the best low-rank copy of a tableEvery matrix is a rotation, a stretch and another rotation. Use the singular value decomposition to compute PCA safely, keep the best rank-k copy of a table, and give PCA a likelihood with probabilistic PCA.Applied · 14 min
  4. 6Projections: the closest point in a smaller spaceDrop a point onto a line or plane and keep what's left over at right angles. Least-squares fits, PCA scores and random projections are all this one move, with different choices of where to project.Applied · 12 min

Unit 3Calculus for learning

· 3 lessons
  1. 7Norms: sizes of vectors, matrices and gradientsOne number for "how big": compare the L1, L2 and max norms, see why an L1 penalty makes zeros and a nuclear-norm penalty makes low rank, and clip a gradient by its global norm without turning it.Applied · 13 min
  2. 8Gradients and the chain ruleThe gradient points uphill on the loss surface, and the chain rule multiplies derivatives through each stage of a model. Work both by hand on a one-neuron model, then see why the same steps scale to millions of weights.Applied · 13 min
  3. 9Autodiff graphs, backpropagation and the gradient checkDraw a program as a graph of small operations, push values forward and derivatives backward, and see why reverse mode gets every gradient for the price of about one extra pass. Then catch a wrong gradient with finite differences.Advanced · 14 min

Unit 4Optimizers

· 3 lessons
  1. 10Stochastic gradient descent and momentumEstimate the gradient from a small batch, accept the noise, and add momentum so steps build up along consistent directions and cancel across a ravine. Then set it up in a CodeSplash learner.Applied · 13 min
  2. 11Adam, AdamW and Adafactor: a step size for every weightAdam scales every weight's step by its own running gradient size. See why its first step is the same size for every weight, why weight decay must be decoupled, and how Adafactor saves memory.Advanced · 15 min
  3. 12Learning-rate schedules: warm up, then cool downThe best learning rate changes during training. Ramp it up while early gradients are wild, then lower it so the weights can settle. Compare constant, step, cosine, one-cycle and plateau schedules, and combine them with clipping.Advanced · 13 min

Unit 5Numbers on a computer

· 2 lessons
  1. 13Tensors, shapes and broadcastingImages, audio, video and batches of series are arrays with more than two axes. Read a tensor's shape as a contract, know the common axis orders, and avoid the broadcasting bug that turns a column plus a row into a square table.Applied · 12 min
  2. 14Floating point, overflow and the log-sum-exp trickComputers keep a fixed number of digits. See where that bites - cancellation, overflow, underflow - and the standard fixes - working in logs, subtracting the maximum before exponentiating, and choosing the precision on purpose.Advanced · 13 min