Skip to content Skip to sidebar Skip to footer

Bug On Keras Fit_generator, Running Few Steps More Than It Should

I found fit_generator() would run few steps more than it should. I set steps_per_epoch=100. i and k both start from 0. But at the end of training process, it will print out k = 109

Solution 1:

No bugs here, it's just some implementation details. The function fit_generator() has a default argument max_queue_size=10. The batches from train_generator and validation_generator will be inserted into queues before getting used to fit/evaluate the model.

When the first epoch ends, there are 100 batches generated (k = 99). However, the generator will continue to generate 10 batches to fill up the queue. That's why you're seeing k = 100 to k = 109. At the same time, the validation process begins, so you'll also see k = 0, ... coming from the validation_generator.

Post a Comment for "Bug On Keras Fit_generator, Running Few Steps More Than It Should"