What is Batch size?
In Turkish: Yığın boyutu (batch size) · Topic: Models and training
The number of training examples a model processes at once before it updates its parameters a single time. It affects training speed, memory use and how noisy the updates are.
How does it work?
Training data is fed to the model not one example at a time or all at once, but in groups of, say, 32 or 256 examples. The model computes the error for every example in the group, averages the gradients and makes one update. A large batch makes better use of the parallel power of graphics cards and gives a less noisy gradient estimate, but needs more memory. A small batch uses less memory and adds noise to the updates, which can sometimes help generalization.
Why does it matter?
Batch size determines how efficiently hardware is used, how fast training runs and whether a model fits in memory. For large models, graphics card memory is limited, so this value is a practical constraint. It is also linked to the learning rate; when the batch size changes, the rate may need retuning.
Example
A team whose training crashes with batches of 64 because the graphics card memory is full can drop the batch size to 16 and keep training.
FAQ
Is a larger batch size always better?
No. A large batch uses hardware more efficiently and gives a steadier gradient, but it needs more memory and can sometimes generalize worse. The best value depends on the task and the hardware.
What can be done if memory is not enough?
The batch size can be reduced, or a technique called gradient accumulation can be used. It sums the gradients of several small batches and makes a single update, with an effect similar to one large batch.