ree·loo
TUTORIAL · NOVICE · SKILLS.READING ≈ B1

PyTorch — a one-evening tour

slug: pytorch · 11 cards · ~25 min. gemini-3.1-pro outline · gemini-3.1-flash-lite bodies · pyodide sandboxes · CPU only

Generated Cached 30d
CARD 01 · CONCEPT

Tensors, not arrays

A tensor is a NumPy array that can live on a GPU and remembers how to differentiate itself. Today we just need the CPU one.

CARD 02 · SANDBOX

Make a tensor

pyodide · seed.py
// output appears here
CARD 03 · CONCEPT

Why requires_grad

If you want PyTorch to track gradients, mark the tensor with requires_grad=True. Otherwise it's just a number.

CARD 04 · QUIZ

Spot the difference

Which tensor below will accumulate gradients?
A.torch.tensor([1., 2., 3.])
B.torch.tensor([1., 2., 3.], requires_grad=True)
C.torch.zeros(3)
CARD 05 · SANDBOX

Compute a gradient

pyodide · seed.py
// output appears here
NEXT 6 CARDS WILL LOAD AS YOU SCROLL
card 6 · sandbox · "Backprop through a tiny MLP" — then concept → quiz → sandbox → checkpoint.