Skip to content

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

Start lesson 1

The 3 phases, lesson by lesson

Phase 1 The autograd engine

  1. 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.
  2. 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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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

  1. 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.
  2. 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.
  3. 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.

Start lesson 1

← Browse all tracks