What are the best strategies for selecting the appropriate batch size?
Answer
Selecting an appropriate batch size is a crucial hyperparameter choice that trades training efficiency against optimization behavior. The practical strategy: start with a moderate value (16, 32, or 64) and adjust based on memory, gradient stability, and validation performance. Three factors drive the choice: memory constraints (larger batches need more GPU memory), dataset size (large datasets can sustain large batches; small datasets often benefit from the extra variability of small batches), and learning rate interaction (large batches usually allow (or require) a proportionally higher learning rate). Large batches train faster per epoch with stabler gradient estimates and higher memory cost, but can converge to sharp minima that generalize worse; small batches update more often with noisier gradients, which can explore flatter minima and generalize better at lower memory cost.
(1) Trade-Off Summary: Large batch = fast and stable but possibly sharp minima; small batch = slow and noisy but often better generalization.
(2) Practical Starting Points: Try 16/32/64 first, then scale with memory and dataset size.
(3) Interaction With LR: Scale the learning rate roughly proportionally when you change the batch size.

Figure 1: Same loss surface, two batch sizes: the small-batch path is noisy but wanders into a wider basin, while the large-batch path is smooth but direct.
Mathematical Formulation:
Where:
is the gradient estimate computed from one mini-batch.
is the batch size, and
indexes the samples in the batch.
is the per-sample loss gradient.
is the per-sample gradient variance; doubling
halves the gradient noise, which is why large batches give stable estimates and small batches give noisy ones.
Leave a Reply