value of steps per epoch passed to keras fit generator function

Keras' generators are infinite.

Because of this, Keras cannot know by itself how many batches the generators should yield to complete one epoch.

When you have a static number of samples, it makes perfect sense to use samples//batch_size for one epoch. But you may want to use a generator that performs random data augmentation for instance. And because of the random process, you will never have two identical training epochs. There isn't then a clear limit.

So, these parameters in fit_generator allow you to control the yields per epoch as you wish, although in standard cases you'll probably keep to the most obvious option: samples//batch_size.


Without data augmentation, the number of samples is static as Daniel mentioned. Then, the number of samples for training is steps_per_epoch * batch size.

By using ImageDataGenerator in Keras, we make additional training data for data augmentation. Therefore, the number of samples for training can be set by yourself. If you want two times training data, just set steps_per_epoch as (original sample size *2)/batch_size.