liveBook · Manning

Batch size

As explained in Evolutionary Deep Learning: Genetic algorithms and neural networks

Batch size is the number of input examples processed in one training update or forward pass.

Batch size is the number of input examples processed together during one forward pass or training update. It is a practical training hyperparameter: changing it can affect how long training takes and how well a model fits the target. section 5.1.1

Treat batch size as part of a linked configuration rather than an isolated number. When data_step generates substantially more training data, increasing batch_size can prevent the training time for a fixed number of epochs from growing dramatically. The useful value depends on the dataset and model, so compare runs instead of assuming one setting always works. section 5.1.1 section 9.1.3

Compare batch-size settings

In a notebook experiment, set batch_size to 2, run the initial 500-epoch training, then change the amount of generated data by lowering data_step. Repeat the run with a larger batch size and compare training time and plotted results. In a GAN exercise, increase or decrease BATCH_SIZE and inspect how training changes. section 5.1.1 section 9.1.3

Listing 5.1 EDL_5_1_Hyperparameter_Tuning.ipynb: Hyperparameters
hp_test = "test 1" #@param {type:"string"}    #1
learning_rate = 3.5e-03
epochs = 500
middle_layer = 25
 
batch_size = 2                                #2
 
data_step = 1                                 #3

Inspect the hyperparameter listing showing batch_size alongside learning rate, epochs, model width, and data_step. section 5.1.1

How Evolutionary Deep Learning: Genetic algorithms and neural networks covers it

How deep it goes
Defines batch size and demonstrates parameter changes experimentally, but stops short of deriving optimization theory or prescribing universal values.
Examples
Demonstrates batch size through a hyperparameter notebook, data_step comparisons, training-time plots, and a GAN digit-generation exercise.
What it assumes
Assumes basic familiarity with neural networks, forward passes, training epochs, hyperparameters, and GANs.
What you can do after
Apply it via notebook parameters by changing batch size, rerunning training, and comparing fit, plots, and training time.
How it connects
Connects batch size with hyperparameter optimization, forward passes, generated datasets, epochs, learning rate, optimizers, and GAN training.

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 Evolutionary Deep Learning: Genetic algorithms and neural networks. The section links point to the parts of the book it draws on.