Index Ai Academy
Phase 4 · Deep learning · Tooling

PyTorch autograd and modules

Let PyTorch compute gradients; build models with nn.Module.

About 35 minutes · Free account required

Open this lesson Create a free account

Why it matters

You've built backpropagation by hand and as a tiny engine. PyTorch's autograd is the same engine for tensors, and nn.Module is how every PyTorch model, from a two-layer classifier to Llama, organizes its weights. After this lesson you can read the model code in most open-source AI projects, and you're one step away from the standard training loop.

What you'll be able to do

  • Get gradients from PyTorch with requires_grad and backward()
  • Control the graph: accumulation and zero_grad, no_grad, detach
  • Build a model as an nn.Module from nn.Linear layers and inspect its parameters
  • Write one manual gradient-descent step on a model

Before this lesson

Next in this phase: GPUs and compute