LESSON 2.33 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW
Gradient accumulation
Watch small microbatches add up to one full-batch step in limited memory.
Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.
Go Pro · $8.25/moEXPLAINER · 2.33 · ACCUMULATION BAYB = 8 · NEEDS 8 · GPU HOLDS 4
01
Stage 1 of 6 · Full batch
A batch of 8 examples gives one gradient, the mean of 8 example gradients. The GPU holds the activations of only 4 examples.
Explain it simply
The model is a line. Training nudges its two numbers, w and c. Each of the 8 examples gives its own gradient. The batch gradient is their average: the dashed red arrow in the buffer panel. One pass over all 8 must keep all their activations, but the memory holds only 4. So the tall block spills over in red.
Eight example cells. A memory block 8 examples tall passes the limit of 4. On the loss map, the full-batch step from θ₀ follows the gradient -1.97, 1.
examples, activationsθ = (w, c), memory limitgradients, buffer, overflowloss contours
Toy: line fit ŷ = w·x + c · 8 examples · memory for 4 · η = 0.5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
The batch gradient is the mean of the example gradients.
PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
- 5 more stages and 3 live controls
- 2 mix-up cards and 3 predict-then-reveal checks
- Watch it as a narrated video, in three voices
- Every Pro lesson and capstone · 656 in total
$99 a year, or $15 a month. Cancel any time.