liveBook · Manning

Batch size

As explained in Machine Learning Platform Engineering

A batch size is the number of training samples processed in one iteration of model training.

Batch size is the number of training samples processed in one iteration. In production training, it is configured alongside learning rate, model architecture, and image size to balance efficiency, resource use, accuracy, and training time. section 8.1.2

When configuring batch size, account for:

  • GPU memory: larger batches can exceed available memory. section 8.1.2
  • Processing speed: increasing the batch size can make processing faster. section 8.1.2
  • Optimization behavior: larger batches can reduce the number of gradient updates and may decrease performance. section 8.1.2
  • Iteration and validation: change the batch size with learning rate or epoch settings when training fails to converge. section 8.1.7

Ultralytics training configuration

A pipeline can pass batch as a configurable value to the Ultralytics YOLO train method. The example uses batch=batch alongside a dataset configuration, image size, epoch count, model name, and artifact directory. section 8.1.2

Listing 8.3 Writing the data configuration to YAML
from ultralytics import YOLO

model = YOLO('yolov8n.pt') #1
results = model.train( #2
    data='custom_data.yaml',
    imgsz=640,
    epochs=epochs,
    batch=batch,
    name='yolov8n_custom',
    project=project_path) #3

Inspect the runnable YOLO training configuration, including the batch parameter and its surrounding production settings. section 8.1.2

How Machine Learning Platform Engineering covers it

How deep it goes
Defines the training-loop parameter, explains memory and performance trade-offs, and stops short of deriving optimization behavior mathematically.
Examples
Uses an Ultralytics YOLO train call with batch=batch and lists batch 4 as a default example, with -1 enabling AutoBatch.
What it assumes
Assumes familiarity with model training parameters and introduces batch size through a concrete YOLO training configuration.
What you can do after
Apply it via Ultralytics YOLO configuration and adjust it when memory, speed, performance, or convergence requires change.
How it connects
Connects batch size with learning rate, epochs, GPU memory, model training, hyperparameter tuning, and convergence.

Also explained in

Compare how 12 books explain batch size →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.