loss.backward() actually doesType an expression the way you would in PyTorch. The page runs it the way an autograd engine does, one node at a time and in four passes: build the graph as Python evaluates the expression left to right, sort the nodes into topological order, run the forward pass in that order, then run the backward pass in reverse. At every node, the chain rule multiplies the upstream gradient by the node's local gradient to get the downstream gradient for each input.
.grad only on leaves (call retain_grad() to keep an intermediate one) and stores plain
Python numbers like 4 inside the operation instead of making nodes for them. Here every node shows its gradient, and
constants are drawn as dashed boxes that get no gradient.+ - * / **, parentheses, sin cos exp log tanh sigmoid relu sqrt abs pow square,
and add sub mul div neg, each as a function (sin(x), torch.pow(x, y)) or a method (x.sin(), x.pow(y)), and several lines of
assignments; the last one is the loss. Every unassigned name is a leaf tensor with requires_grad=True.
Keys: → step, ← back, space play. Click a node to zoom into it, or an edge in the zoom to follow it; the dashed box on the graph shows where the zoom is looking.