In Keras documentation - steps_per_epoch: Total number of steps (batches of samples) to yield from generator before declaring one epoch finished and startin
The steps_per_epoch
parameter is the number of batches of samples it will take to complete one full epoch. This is dependent on your batch size. The batch size is set where you initialize your training data. For example, if you're doing this with ImageDataGenerator.flow()
or ImageDataGenerator.flow_from_directory()
, the batch size is specified with the batch_size
parameter in each of these.
You said you have 3000 samples.
steps_per_epoch
would be 30.steps_per_epoch
would be 300. steps_per_epoch
would be 3000. This is because steps_per_epoch
should be equivalent to the total number of samples divided by the batch size. The process of implementing this in Keras is available in the two videos below.
The reason why you have to set steps_per_epoch
is that the generator is designed to run indefinitely (See the docs:
"The generator is expected to loop over its data indefinitely."
). You implemented this by setting while 1
.
Since fit_generator()
is supposed to run epochs=x
times, the method must know when the next epoch begins within this indefinitely loop (and, hence, the data has to be drawn from the beginning again).