bobofamilyNIU CHUN
Tags10

#Backpropagation

2026-09-20·—READS·—LIKES·Learning AI with AI

Off by 0.0001: Twenty-Six Steps Compressed into Six, and Hand-Derived Gradients Training the Same Model

The previous three parts derived all twenty-six steps from the loss to every parameter, but that was opening the black box and walking through it. This one puts the box back together: cross-entropy's eight steps compressed into one line, BatchNorm's ten into one, both by the same method — count how many times a variable appears in the forward pass and the backward has that many terms. Then backward() is commented out and the model trains for 200,000 steps: val loss 2.1105, against PyTorch's 2.1106.

2026-09-18·—READS·—LIKES·Learning AI with AI

The Line That Looks Right: 96 Lookups Landing on 27 Rows, and the End of Ex1

Five steps left, no forks, and the first three are a copy of the previous part. What is genuinely new is the last two: why view's backward is simply its own inverse (one test decides it — did the count of numbers change), and why dC[Xb] += demb, a line that looks entirely correct, is wrong. Finish these five and all 4137 parameter gradients have been worked out by hand.

2026-09-18·—READS·—LIKES·Learning AI with AI

The Same Deviation Is Both Numerator and Denominator: Thirteen Steps Back Through BatchNorm

The previous part stopped at logits — the edge of the network, with not one parameter touched in eight steps. This one goes thirteen steps further in, and parameters appear for the first time. BatchNorm's nine steps are the worst stretch in the episode for the same reason softmax forks: a normalisation's numerator has to go build the denominator first. Along the way: the first sum-backward whose coefficient is not 1, and a mistake only 3% wide whose maxdiff looks like rounding error.

2026-09-16·—READS·—LIKES·Learning AI with AI

Maths Catch-Up · Summation Is What Reuse Costs: sum(0) or sum(1), Just Compare the Indices

Part 3 gave the Σ of the multivariable chain rule and part 13 used it to derive the linear layer — but that was one special case. This part turns it into a general method: the addition comes from the total differential, the four shapes differ only in which entries of one Jacobian are zero, and whether to sum or broadcast — and along which axis — reads straight off the two index sets.