Module 1 · Learning from data · Lesson 3
Loss functions and gradient descent
Fit a line to hours-to-resolve by hand in numpy, from defining a loss to taking its gradient, stepping downhill, choosing a learning rate and reading the loss curve, and see why every training run in the LLM courses reports the same curve.
By the end of this lesson you can
- Write mean squared error for a linear model and compute its gradient with respect to the weights by hand for a two-feature example
- Explain what a gradient is without calculus notation, as the direction and rate at which a small change in each parameter changes the loss
- Implement batch gradient descent in numpy and reproduce scikit-learn's LinearRegression coefficients to three decimals
- Recognise divergence, convergence and a too-small step from a loss curve, and explain why features are standardised before gradient descent
- Describe mini-batches, momentum and what Adam adds, and explain why language-model training reports a loss at all
