Keras: ImageDataGenerator Epoch comprised more than `samples_per_epoch` samples

Created on 19 Jul 2016  路  3Comments  路  Source: keras-team/keras

UserWarning: Epoch comprised more than samples_per_epoch samples, which might affect learning results. Set samples_per_epoch correctly to avoid this warning.

I have around 20k training images,

        train_datagen = ImageDataGenerator(
                zoom_range=0.2,
                rotation_range=20,
            width_shift_range=0.1,
            height_shift_range=0.1,
                horizontal_flip=False)
...
...
model.fit_generator(
                train_datagen.flow(train_data,train_target,batch_size=40,shuffle=1),
                samples_per_epoch=2520,
                nb_epoch=400)

Ideally this should train with 2520 each epoch, however I gives 2507 on the 9th epoch every time. It says " UserWarning: Epoch comprised more than samples_per_epoch samples, which might affect learning results. Set samples_per_epoch correctly to avoid this warning."

stale

Most helpful comment

I had this warning and solved it by having samples_per_epoch a number that can be divided by batch_size
e.g. batch_size 32 ... and samples_per_epoch 256

All 3 comments

I had this warning and solved it by having samples_per_epoch a number that can be divided by batch_size
e.g. batch_size 32 ... and samples_per_epoch 256

@abdelrahmansaud is right, this warning occurs because the number of samples in your training set cannot be divided envenly. You have 20K training images, perhaps you should set samples_per_epoch to 2500.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, but feel free to re-open it if needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fredtcaroli picture fredtcaroli  路  3Comments

vinayakumarr picture vinayakumarr  路  3Comments

oweingrod picture oweingrod  路  3Comments

snakeztc picture snakeztc  路  3Comments

harishkrishnav picture harishkrishnav  路  3Comments