Build Neural Networks from Scratch
Track 13 · Intermediate
Build an autograd engine and a neural net from nothing.
10 lessons 2.1 hours narrated Free, no account needed
The 3 phases, lesson by lesson
Phase 1 The autograd engine
- Building an autograd engine: micrograd How a neural network computes gradients automatically: build micrograd in your head with a computational graph, local derivatives, and backpropagation.
- Building and training a net: micrograd Assemble neurons into a multilayer perceptron, measure error with a single loss number, and train it by gradient descent, the same loop GPT learns by.
Phase 2 Building a language model
- Your first language model: the bigram model A language model assigns probabilities to what comes next. Build a character-level bigram model that learns name statistics, by counting and as a neural net.
- Giving the model memory: the MLP language model Extend makemore to a multilayer perceptron with learned character embeddings, the lookup table of vectors that lets a model read several characters of context.
- Why deep nets won't train: BatchNorm and init Deep networks fail to train in two ways: a confidently wrong start and saturated neurons. Fix both with scaled weight initialization and batch normalization.
- Becoming a backprop ninja: gradients by hand Backpropagate softmax and cross-entropy by hand and reach the clean result that the gradient on the logits is the predicted probabilities minus the true label.
- Building understanding in layers: WaveNet Restructure the flat MLP into a WaveNet-style hierarchy that fuses context two groups at a time, doubling the span each layer sees; the idea behind depth.
Phase 3 Building a transformer
- Building GPT: self-attention from scratch Build self-attention from scratch in a GPT: each token emits a query and key whose match decides who it attends to, with a causal mask blocking the future.
- Assembling and training the full GPT Assemble self-attention into a full GPT: multi-head attention, the transformer block, residuals, layer norm, positional embeddings, next-token training.
- Building the GPT tokenizer Build the GPT tokenizer from scratch: byte-pair encoding that merges common character pairs into tokens, turning text into the IDs a GPT reads and back.