internalsGet Pro

Machine Learning Engineering · Module 06

How models learn: losses and training

Lessons
9
Free
1
Reading
~2 h

Your progress

0 / 9 lessons done

Sign in to track

Lessons

  1. Models as functions with learnable parametersEvery model you train, save, ship or debug is a formula someone wrote plus numbers training found. Knowing which part is which tells you what a training run can change, what a model file must carry, and why a model can fail silently when the two drift apart.12 min
  2. Loss functions: measuring how wrong a model isEvery training run lowers one number, and that number is rarely the one your team is paid on. Knowing what a loss measures, and what it ignores, is how you avoid shipping a model that improved on paper and lost money on Monday.13 min
  3. Common losses: squared error to cross-entropyThe loss is the one line of a training script that decides what the model is trying to predict. Pick the wrong one and training succeeds at the wrong goal: a budget that comes out lakhs short, or a classifier that stops learning from its worst mistakes.14 min
  4. The training loop: predict, measure, adjustEvery model you train in PyTorch, and most you train with other libraries, runs the same few lines in a loop. Knowing what each line does, and how the loop decides to stop, is how you read a training log and find the bug when a run goes wrong.13 min
  5. Bias and variance: two kinds of errorWhen a model is not good enough, the fix depends on where its error comes from. More data, a bigger model and better features each attack a different part, and picking the wrong one wastes weeks.16 min
  6. Overfitting and underfittingFreeEvery model you train reports a training loss, and that number always looks better than the model really is. Reading it next to a held-out loss is how you decide whether to ship, add features, collect data or stop training earlier.13 min
  7. Regularization: L1, L2 and early stoppingAlmost every model you train has a regularization setting, often switched on by default: C in scikit-learn’s logistic regression, weight_decay in PyTorch’s optimizers, the patience of an early-stopping check. Knowing what each one does to the weights is how you set it on purpose instead of leaving it to chance.17 min
  8. Train, validation and test setsEvery model score you report was measured on some set of examples. If that set also helped choose the model, the score is too good, and the people who act on it find out only after launch.13 min
  9. Cross-validation: getting more from little dataMost real ML projects start with less labelled data than anyone wants: a pilot, a new market, a rare event. Cross-validation is how you get a score you can trust from that data, and the wrong kind of folds is one of the most common ways teams fool themselves.17 min

Practise with