From one linear model to backpropagation, then the formulas as PyTorch that runs.

17 core notes, about 2 h. 7 deep dives fold under the notes they extend.

From prediction to neural networks4 core · 1 deep

How a linear model becomes a network, the maths it needs, and why vectors carry meaning

  1. Starting out: make one small example clearCompute a loss by hand; one gradient step takes it from 2.5 to 0.625, then tensors5 min
  2. From linear models to neural networksOn XOR, the same 33 parameters score 50% without an activation and 100% with one ReLU18 min
  3. From one matrix multiply to gradients, memory, and multiple GPUsWork out dW = XᵀG: why backward needs saved inputs, and why GPUs combine gradients7 min
  4. ML mathematics: from probability to estimatorsWhy the CE gradient is p − y, L1 gives exact zeros, and BLUE needs no normality7 min
  5. Why vectors can represent meaningMeaning comes from training; for one query, dot product picks (2,2) and cosine (1,0)4 min

What one training step does4 core · 1 deep

One update from loss to weights: why training stalls or overfits, and what optimizers change

  1. What happens in one language-model training stepThe output at SEP predicts the answer: shift by one, and what three masks each do3 min
  2. Good on Training Data, Poor on New Data?Check splits and leakage first, then why L1 zeroes a weight while L2 only shrinks it6 min
  3. Activations and Initialization: Where Did the Gradient Go?Confidently wrong, the CE gradient is still near 1; after 20 ReLU layers, He keeps ~18 min
  4. From SGD to AdamW: What Changes in One Update?What momentum and adaptive steps do, and why AdamW's decay isn't Adam plus L22 min
  5. Muon: updating a matrixScaling the update diag(6,2) keeps 3:1; Muon's orthogonalization makes it 1:19 min

Sequence models2 core · 1 deep

Sequences before Transformers: RNN, LSTM, Seq2Seq, and why gradients vanish

  1. RNN and LSTM50 steps back: plain RNN gradient 2.9×10⁻⁹, an LSTM with forget gate 0.99 still 0.618 min
  2. Sequence gradients, BPTT, and gates0.9 per step leaves 0.005 after 50 steps; truncated BPTT keeps state, cuts gradients5 min
  3. Seq2Seq: encode and generateAttention rereads the input each step; training on true prefixes leaves exposure bias4 min

PyTorch: from tensors to training6 core · 1 deep

Formulas as training code: storage, shapes, cross-entropy, autograd and the training loop

  1. PyTorch: from equations to training codeStorage, shapes, CE, autograd, then the loop; one step takes CE from 0.693 to 0.5794 min
  2. Python: names, copies, and function callsWhy editing a copy changes the original: mutation versus rebinding, copies, calls7 min
  3. Tensors and storage: which data did you change?Edit a slice and the original changes: views share storage; reshape is not transpose6 min
  4. Operations and shapes: valid code can compute the wrong thingExact predictions, MSE 2: [2,1] minus [2] broadcasts to [2,2] and compares all pairs5 min
  5. Cross-entropy: from one prediction to a training loss0.9 on the right class costs 0.105, 0.01 costs 4.605; computing it stably from logits8 min
  6. Autograd: computed gradients are not always stored gradientsOnly leaf tensors keep .grad; backward accumulates; detach, no_grad and eval differ7 min
  7. From batches to a training loop: running is not learningBatches of 16 and 1 with losses 1 and 9 average 1.47, not 5: count the denominator12 min

Writing the code1 core · 3 deep

Write it once without a framework: BPE, LSTM, attention, losses and sampling

  1. Seven ML modules to implement by handSubtract the max, mask before softmax, and which two of [2,2,2,1] top-2 keeps7 min
  2. Build-it-yourself labs: from symbols to generationEach piece twice: BPE, LSTM and attention without a framework, then in PyTorch4 min
  3. ML coding: PyTorch & implementationsTwo routes: PyTorch training code, or attention, losses and sampling by hand2 min
  4. One attention, five ways: from MHA to MLAA few lines at a time; per-token cache goes 64 (MHA), 32 (GQA), 16 (MLA)4 min