Small batches give noisy gradients (a mild regularizing effect) and need less memory but use hardware less efficiently.
Large batches give smoother gradients and better GPU utilization, but may generalize worse and usually need a proportionally larger learning rate (often with warmup).
If memory limits the batch size, use gradient accumulation: sum gradients over several small batches before one optimizer step.
Loading…