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.
| batch 1 | batch 2 | batch 3 | batch 4 |
|---|---|---|---|
| 1 | 2 | 3 | 2 |
| batch 1 | batch 2 | batch 3 | batch 4 |
|---|---|---|---|
| 8 | 8 | 8 | 8 |