The difference in forecasts between model.predict () and model.predict_generator () in keras

When I use model.predict_generator()in mine test_set (images), I get a different prediction, and when I use mode.predict()in the same test_Set, I get a different set of predictions.

For use, model.predict_generatorI followed the steps to create a generator:

  • Imagedatagenerator (no argument here) and the file flow_from_directory with shuffle = False.
  • There are no additions or preprocessing images(normalization,zero-centering etc)during model training.

I am working on a binary classification problem related to dogs and cats (from kaggle). On the test set I have 1000 images of cats. and using model.predict_generator(), I can get 87% accuracy()ie 870 images are classified correctly. But when using model.predict, I get an accuracy of 83%.

This is confusing because both have to give the same results right? Thanks in advance:)

+4
source share
1 answer

@petezurich Thank you for your comment. Generator.reset () before model.predict_generator () and disabling shuffling in pred_generator () fixed problem

+1
source

Source: https://habr.com/ru/post/1681502/


All Articles