

More examples can be created by data augmentation, i.e., change brightness, rotate or shear images to generate more data.

Run the following cell to see the results. Because steps * batch_size = number_of_images_trained in an epoch a common practice, that we will use here, is to set the number of steps equal to the non-augmented dataset size divided by the batch_size (which has a default value of 32).

We explicitly set how long we want each epoch to run using the steps_per_epoch named argument. Generators can supply an indefinite amount of data, and when we use them to train our data, we need to explicitly set how long we want each epoch to run, or else the epoch will go on indefinitely, with the generator creating an indefinite number of augmented images to provide the model. This causes the images to get augmented live and in memory right before they are passed into the model for training. When using an image data generator with Keras, a model trains a bit differently: instead of just passing the x_train and y_train datasets into the model, we pass the generator in, calling the generator's flow method.
