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
- 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
- From linear models to neural networksOn XOR, the same 33 parameters score 50% without an activation and 100% with one ReLU18 min
- 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
- ML mathematics: from probability to estimatorsWhy the CE gradient is p − y, L1 gives exact zeros, and BLUE needs no normality7 min
- 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
- What happens in one language-model training stepThe output at SEP predicts the answer: shift by one, and what three masks each do3 min
- 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
- 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
- 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
- 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
- RNN and LSTM50 steps back: plain RNN gradient 2.9×10⁻⁹, an LSTM with forget gate 0.99 still 0.618 min
- Sequence gradients, BPTT, and gates0.9 per step leaves 0.005 after 50 steps; truncated BPTT keeps state, cuts gradients5 min
- 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
- PyTorch: from equations to training codeStorage, shapes, CE, autograd, then the loop; one step takes CE from 0.693 to 0.5794 min
- Python: names, copies, and function callsWhy editing a copy changes the original: mutation versus rebinding, copies, calls7 min
- Tensors and storage: which data did you change?Edit a slice and the original changes: views share storage; reshape is not transpose6 min
- 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
- 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
- Autograd: computed gradients are not always stored gradientsOnly leaf tensors keep .grad; backward accumulates; detach, no_grad and eval differ7 min
- 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
- Seven ML modules to implement by handSubtract the max, mask before softmax, and which two of [2,2,2,1] top-2 keeps7 min
- Build-it-yourself labs: from symbols to generationEach piece twice: BPE, LSTM and attention without a framework, then in PyTorch4 min
- ML coding: PyTorch & implementationsTwo routes: PyTorch training code, or attention, losses and sampling by hand2 min
- 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
No notes match.