Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Machine Learning Foundations for LLM Work

Free · sign in to start and track progress

1 · Learning from data

  • 1Problems, data and baselines
  • 2Train, validation, test and leakage
  • 3Loss functions and gradient descent

    Exercise answers

    • Answer: Fit a line by gradient descent in numpy
    • Answer: Mini-batches and momentum

2 · Classifiers and generalisation

  • 4Logistic regression, step by step
  • 5Metrics, thresholds and calibration
  • 6Overfitting, regularisation and cross-validation

3 · The maths the later courses assume

  • 7Probability for evaluation
  • 8Standard errors, intervals and paired tests
  • 9Vectors, dot products and embeddings
  • 10A small neural network from scratch
CapstoneTicket triage you can defendReference implementation

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.

75 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvThe Hollowbrook ticket data

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

On this page

  • A model and a loss
  • The model
  • The loss
  • Downhill
  • The gradient without calculus
  • The gradient of mean squared error
  • Worked by hand
  • The learning rate
  • Why features are standardised
  • Batches, noise and momentum
  • Why LLM training reports a loss
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01A model and a loss
  2. 02Downhill
  3. 03The learning rate
  4. 04Batches, noise and momentum
  5. 05Why LLM training reports a loss
  6. 06Connections
  7. 07Summary

Sources & further reading

  • An overview of gradient descent optimization algorithmsPaper · Ruder · 2016Sections 2 and 3 cover batch, stochastic and mini-batch descent and the challenges (learning rate, plateaus); section 4 is the catalogue of momentum, RMSprop and Adam.
  • Adam: A Method for Stochastic OptimizationPaper · Kingma, Ba · 2014The optimiser the fine-tuning course uses. Section 2, the algorithm, is one page and readable after this lesson.
  • Linear regression: gradient descentLab research · GoogleThe learning-rate and convergence pages, with interactive loss curves to play with after the predict-then-check exercise.
  • CS229 Lecture NotesUniversity · Ma, Ng · Stanford · 2026Chapter 1, Linear regression, section 1.1 (the LMS algorithm), derives the same gradient as this lesson in the same notation, then gives the closed form the exercise checks against.
  • Learning Data Science, chapter 15: Linear ModelsUniversity · Lau, Gonzalez, Nolan · UC Berkeley · 2023The Data 100 textbook's treatment of fitting linear models by minimising a loss in numpy, at exactly this level.
  • Deep Learning, chapter 4: Numerical ComputationBook · Goodfellow, Bengio, Courville · 2016Section 4.3, gradient-based optimisation, is the formal version of the downhill idea, including why the gradient is the direction of steepest ascent and what conditioning does to step sizes.
  • NumPy: the absolute basics for beginnersDocs · NumPyArrays, shapes, `@` and broadcasting, which is all the numpy the exercise needs.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 7 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks