You want to train on batches of 32 photos, but only 8 fit in memory at once. So you run small batches one after another, and each reports the average slope over its own photos (the slope from “Walk downhill”). Write big_batch_slope(batch_slopes, batch_sizes): the slope one big batch of all those photos would give, so the step you take is the same.
30 photos to train on, but the GPU only holds 8 at a time. So they run in batches of 8, 8, 8 and the 6 left over, and each batch reports the average slope over its own photos. What you wanted was the slope of one batch of all 30.
big_batch_slope(batch_slopes, batch_sizes)| batch_slopes | each small batch's AVERAGE slope over its photos | e.g. [0.7] |
| batch_sizes | how many photos were in each small batch | e.g. [32] |
| returns | the slope one big batch of all those photos would give | |