0
votes

I was using the fit function for a while now, but now I need to make some augmentation to the dataset that I have, so I have to use fit_generator. There are some things I don't understand about fit_generator.

Why there is a batch_size option inside flow function? How does it behave when I use it with the steps_per_epoch parameter? Is there a way to know how many images are generated with the imagedatagenerator function?

model.fit_generator(datagen.flow(x, y,batch_size=32), steps_per_epoch=len(x)/32,epochs=50)
1

1 Answers

1
votes

A data generator produces batches of data, meaning that for image data it produces numpy arrays with the shape (batch_size, image_height, image_width, channels). fit_generator takes these batches one at a time (and trains on them, obviously). steps_per_epoch defines the number of batches in an epoch. The number of images generated per batch is whatever you tell it, and the total number of images is infinite (though it will eventually loop around and start producing duplicates)