When I use model.predict_generator()
on my test_set (images)
I am getting a different prediction and when I use mode.predict()
on the same test_Set
I am getting a different set of predictions.
For using model.predict_generator
I followed the below steps to create a generator:
Imagedatagenerator
(no arguments here) and used flow_from_directory
with shuffle = False.
images(normalization,zero-centering etc)
while training the model.I am working on a binary classification problem involving dogs and cats (from kaggle).On the test set, I have 1000 cat images.
and by using model.predict_generator()
I am able to get 87% accuracy()
i.e 870 images are classified correctly.
But while using model.predict I am getting 83% accuracy.
This is confusing because both should give identical results right? Thanks in advance :)
Keras model predicts is the method of function provided in Keras that helps in the predictions of output depending on the specified samples of input to the model.
predict_generator. (Deprecated) Generates predictions for the input samples from a data generator.
(Deprecated) Evaluates the model on a data generator.
@petezurich Thanks for your comment. Generator.reset() before model.predict_generator() and turning off the shuffle in predict_generator() fixed the problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With