5.6.10 · D5Machine Learning (Aerospace Applications)
Question bank — Batch, mini-batch, stochastic gradient descent
Before diving in, three words you must already own (all built in the parent note):
- Gradient estimate — our guess of the true downhill direction , built from a subset of data.
- Batch size — how many training examples feed into one (and therefore one parameter step).
- ==Variance of == — how much jitters around the true gradient from step to step; it scales like .
Everything here leans on those and on Gradient Descent, Learning Rate and Schedules, and the non-convex landscapes of Saddle Points and Non-Convex Optimization.
True or false — justify
"Batch GD always reaches a lower final loss than SGD."
False. Batch GD finds the exact gradient per step but takes few steps; SGD's noise often lands in flatter, better-generalising minima, so final loss is comparable or better — see Bias-Variance Tradeoff.
"SGD uses exactly one example per epoch."
False. SGD uses one example per update; an epoch is a full pass over all examples, so pure SGD makes updates per epoch.
"Increasing batch size from 1 to 32 and from 256 to 512 reduce noise by the same factor."
False. Variance falls like , so cuts it 32-fold while only halves it — diminishing returns are the reason mid-size batches win.
"Mini-batch GD is a compromise, so it must converge slower than both extremes."
False. It usually beats both in wall-clock time: cheaper steps than Batch, less wasted jitter than SGD, and GPU-friendly parallel arithmetic.
"The update rule is different for each of the three methods."
False. The rule is identical; only the definition of (the subset it averages over) changes.
"A larger batch always lets you keep the same learning rate safely."
False. Larger shrinks gradient variance, so you can afford a bigger ; the linear scaling rule says . Keeping fixed under-uses the cleaner gradient. See Learning Rate and Schedules.
"Because SGD is unbiased, its every single step points downhill."
False. Unbiased means on average it points downhill (); any individual step can point sideways or even uphill.
"With a fixed learning rate, SGD converges to the exact minimum."
False. Fixed leaves SGD bouncing in a neighbourhood of the minimum forever; only a decaying schedule pins the true point.
Spot the error
Claim: "Batch gradient ."
Missing the average. Without it grows with dataset size, making the effective step wildly -dependent — the definition is the mean .
Claim: "For SGD, for one random ."
No factor belongs there. SGD's estimate is just ; dividing by would shrink every step by and break unbiasedness.
Claim: "The step is because we descend."
Sign error. Descending means going opposite the gradient: . A plus sign climbs the loss.
Claim: ", gives updates per epoch."
Reversed ratio. Updates per epoch , not or .
Claim: "Variance of scales like , so noise drops slowly."
The variance itself scales like ; it is the standard deviation (the square root) that scales like . Mixing the two mis-states the trade-off.
Claim: "The Taylor step used the second-order term to justify descent."
The descent direction argument only needs the first-order term ; the Hessian term belongs to curvature methods, not the plain gradient-descent derivation.
Claim: "Averaging i.i.d. gradients halves the variance when doubles, so it is linear in ."
It is , which does halve variance on doubling — but the phrase "linear in " is wrong wording: variance is inversely proportional to , not linearly proportional.
Why questions
Why do we approximate with a subset instead of always computing the exact full-data gradient?
The exact sum over all samples is too expensive when is huge (millions of CFD or sensor samples); a subset gives a good-enough direction far more cheaply per step.
Why is a little gradient noise sometimes helpful rather than harmful?
Noise can bounce the parameters out of saddle points and shallow local minima that plague non-convex nets, letting training reach better regions — relevant to Saddle Points and Non-Convex Optimization.
Why does the step point anti-parallel to the gradient specifically?
From the first-order Taylor term , the dot product is most negative (fastest decrease) when opposes , by Cauchy–Schwarz.
Why can very large batches generalise worse despite cleaner gradients?
Low noise tends to settle into sharp minima that fit training data tightly but transfer poorly; some noise nudges toward flatter, more robust minima — a Bias-Variance Tradeoff in disguise.
Why does mini-batch often beat Batch GD in wall-clock time even though each Batch step is "more correct"?
Batch makes only one costly update per epoch; mini-batch makes cheap, good-enough updates in the same pass, so total progress per second is greater.
Why must the learning rate eventually shrink for SGD to truly converge?
A fixed keeps the stochastic bounce alive around the minimum; a schedule damps that bounce so the iterates settle on the actual minimum. See Learning Rate and Schedules.
Edge cases
What is SGD when the dataset has exactly one sample, ?
All three methods collapse to the same thing: Batch, SGD, and mini-batch each use that single example, so is identical and exact every step.
What happens to when ?
It becomes the variance of the full-data average, the smallest achievable from this data; for the true objective the estimate is exact, so the sampling noise vanishes.
If is not divisible by (say , ), how many updates per epoch?
You get updates: three full batches of 300 plus one leftover batch of 100 (the final batch is simply smaller).
What is the effective batch behaviour if you set larger than ?
You cannot draw more distinct samples than exist, so it caps at Batch GD (); asking for just reuses data or is clamped to the full set.
At a saddle point where exactly, what does each method do?
Batch GD's so it stalls indefinitely; SGD/mini-batch have nonzero noise ( per sample) that kicks it off the saddle and lets training continue.
What does do regardless of batch size?
The update makes no change at all — parameters freeze, so no learning happens no matter how good is.
As (infinite i.i.d. data per step), what does the mini-batch gradient approach?
Its variance , so converges to the true expected gradient — mini-batch becomes indistinguishable from exact Batch GD in direction.
Recall One-line self-test before you close the tab
Cover the answers and re-derive: (1) updates per epoch ; (2) ; (3) step direction ; (4) unbiased means , not "always correct". If all four came instantly, you own the topic.