What if the sample size is not divisible by batch_size in Keras model


What if we specify batch size as 15 and the sample size of 1000 which is not divisible by 15 in Keras model training?.should it still able to train?

also I have looked in to this answer but it’s not helping question

please can anybody explain this Thank you.


I found the answer for this. If this is the case, it will take it will take the remaining 10 samples to the last step of the epoch.

Eg: 15x66+10=1000 that means it will take 66 batches of size 15 and for the final steps it takes only 10.

Anyways this will only work with input_shape, if we use batch_input_shape it will give us an error because we are specifying the batch shape in the graph level.

Answered By – Dulmina

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published