简体   繁体   中英

Are all train samples used in fit_generator in Keras?

I am using model.fit_generator() to train a neural network with Keras . During the fitting process I've set the steps_per_epoch to 16 ( len(training samples)/batch_size ).

If the mini batch size is set to 12, and the total number of training samples is 195, does it mean that 3 samples won't be used in the training phase?

No, because it is a generator the model does not know the total number of training samples. Therefore, it finishes an epoch when it reaches the final step defined with the steps_per_epoch argument. In your case it will indeed train 192 samples per epoch.

If you want to use all samples in your model you can shuffle the data at the start of every epoch with the argument shuffle .

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