About this course
You call loss.backward() every day — but what actually happens inside that one line? In this
course you don't memorize concepts, you build the thing: first a Value class that remembers
how it was computed, so gradients flow backwards through the graph automatically; then a
finite-difference audit that proves, op by op, that your backprop is correct. Next you upgrade
the scalar engine into a tensor engine that eats numpy arrays — backprop through broadcasting
and the two transpose rules of matmul, no hand-waving. On top of it you build your own torch.nn
and torch.optim: Module, Linear, numerically-stable cross-entropy, SGD and Adam. Finally you use
this mini-PyTorch — every line yours — to train XOR, a two-moons classifier and a character-level
name generator, and map it all back to real PyTorch: detach, no_grad, and the memory bill.
Pure Python + numpy, fully offline, every step runs in your own sandbox in under a second.
By the end you'll see it plainly: the heart of PyTorch is a few dozen lines you wrote and verified yourself.
What you'll learn
- Hand-implement a graph-recording Value class and a topological-sort backward() — every line behind loss.backward()
- Audit analytic gradients against finite differences op by op, proving your backprop correct and catching a planted derivative bug
- Upgrade the scalar engine into a numpy tensor autograd: derive and implement backprop through broadcasting and matmul's two transpose rules
- Build your own torch.nn and torch.optim: Module/Linear/stable cross-entropy/SGD/momentum/Adam
- Train XOR, a two-moons classifier and a character-level name generator from scratch on your own engine, with deterministic assertions
- Explain real PyTorch's internals: why reverse mode wins, the activation-memory bill and checkpointing, what detach/no_grad do
Syllabus
1A Backprop Engine: from Scalar Autograd to Training an MLP3 sessions
2The Op Zoo & Gradient Audits: Hardening Your Engine3 sessions
3Tensor Autograd: Teaching Your Engine numpy3 sessions
4Build Your Own torch.nn & torch.optim0 sessions
Sessions are on the way.
5Capstone: Train Real Models on Your Mini-PyTorch0 sessions
Sessions are on the way.
6Under the Hood: Your Engine vs Real PyTorch0 sessions
Sessions are on the way.
Same series · 人工智能全透析
AI, End to End
Synthesized from the best material across the web — rebuild the core of AI from scratch, the efficient way.