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

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

    Exercise answers

    • Answer: The MLP in numpy, then in PyTorch, then against logistic regression
    • Answer: Dropout and weight decay on the validation curve
CapstoneTicket triage you can defendReference implementation

Module 3 · The maths the later courses assume · Lesson 10

A small neural network from scratch

The forward pass as two matrix products and a non-linearity, backpropagation as the chain rule applied layer by layer, and a training loop, first in numpy on the ticket features and then as the same model in PyTorch on CPU, scored against logistic regression with a paired test.

90 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvThe Hollowbrook ticket dataRun Hugging Face models on CPU

By the end of this lesson you can

  • Write the forward pass of a one-hidden-layer MLP as two matrix multiplications and a non-linearity, and count its parameters
  • Explain backpropagation as the chain rule applied layer by layer and compute the output-layer gradient by hand for one example
  • Implement the MLP and its training loop in numpy, then in PyTorch with nn.Module, autograd and an optimiser, and verify that the gradients agree
  • Use a validation set for early stopping and compare the MLP with logistic regression using a paired bootstrap
  • Describe what changes between this MLP and a transformer block, as a bridge to the LLM courses

On this page

  • The forward pass
  • The loss and the gradient at the output
  • Backpropagation is the chain rule, layer by layer
  • The training loop, in numpy and in PyTorch
  • Did it beat logistic regression?
  • From this MLP to a transformer block
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01The forward pass
  2. 02The loss and the gradient at the output
  3. 03Backpropagation is the chain rule, layer by layer
  4. 04The training loop, in numpy and in PyTorch
  5. 05Did it beat logistic regression?
  6. 06From this MLP to a transformer block
  7. 07Connections
  8. 08Summary

Sources & further reading

  • Deep Learning in Neural Networks: An OverviewPaper · Schmidhuber · 2014The history, for perspective. Section 5 traces backpropagation from the 1960s and 70s to its 1986 popularisation; skim it once.
  • Understanding the difficulty of training deep feedforward neural networksPaper · Glorot, Bengio · 2010Why the scale of the initial weights matters and where the scaled-uniform initialisation in the exercise comes from; section 4 (the normalised initialisation).
  • Adam: A Method for Stochastic OptimizationPaper · Kingma, Ba · 2014The optimiser the PyTorch model uses. Section 2 (the algorithm) is enough; it is also the optimiser every fine-tuning run in the later courses uses.
  • Neural networksLab research · GoogleAn interactive walk through hidden layers and activation functions, useful if the matrix view below feels abstract.
  • CS229 Lecture Notes, part II: Deep learningUniversity · Ma, Ng · Stanford · 2026Chapter 7, sections 7.2 (neural networks) and 7.4 (backpropagation), with the vectorised gradient formulas this lesson's numpy code implements.
  • Deep Learning, chapter 6: Deep Feedforward NetworksBook · Goodfellow, Bengio, Courville · 2016Sections 6.1 to 6.5. The XOR example for why a hidden layer is needed, hidden units and ReLU, and back-propagation written out for exactly this architecture.
  • Automatic Differentiation with torch.autogradDocs · PyTorchHow `.backward()` fills `.grad`, why gradients accumulate unless zeroed, and `torch.no_grad()`; the companion page on the optimisation loop is linked from it.
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.

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