Skip to content
Machine learning

Machine learning from scratch: 36 lessons

Each lesson teaches one idea in plain words, follows one example by hand, and ends with a small exercise in Python with tests. They go from the math every model uses to a small GPT.

Math foundations

The few pieces of math every later chapter uses: how a model is scored, and how it is nudged to do better.

Neural networks

Build a network from single neurons by hand, and see how the error travels backwards through it.

PyTorch

Do the same math with tensors, the tool real models are written in, and meet three ways to keep numbers at a steady size.

Training

Run a real training loop, and learn to read the signs that it is going well or badly.

NLP

Turn text into numbers a model can use: tokens, vectors, and a sense of word order.

Attention & transformers

The step that lets each token look at the tokens before it, and the block that is built around it.

Build GPT

Put it together: a tokenizer, training data, a small GPT, and the loop that makes it write.