简体   繁体   中英

Keras fit_generator - ImageDataGenerator behaviour

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)

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM