Foundations
PyTorch primer
The PyTorch you need for the rest of the book: tensors and shapes, linear algebra, autograd, randomness, and keeping numbers stable. Each chapter reuses examples from the Maths toolkit.
Start course 6 lessons · 2 levels
Level 1·Tensors and linear algebra
- TensorsA tensor is PyTorch's grid of numbers, and each maths operation from Section 1 is one short line on it.
- Shapes and broadcastingPyTorch lines shapes up from the right and reuses sizes of 1, so one line handles a whole batch.
- Linear algebra in PyTorchTorch.linalg solves systems, finds eigenvalues and powers matrices. Picking the right call keeps answers accurate.
Level 2·Gradients, randomness and numbers
- Autograd: derivatives in PyTorchAutograd records every step your code takes, then runs the chain rule backwards to give you exact derivatives.
- Randomness and distributionsSeeds, random tensors and torch.distributions: spin the delivery spinner, sample the delivery times and walk the Markov chain in code.
- Numbers and stabilityWhy float32 rounds, overflows and underflows, and the log-space tools and loss functions that keep training numbers safe.