简体   繁体   中英

difference in predictions between model.predict() and model.predict_generator() in keras

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:

  1. Imagedatagenerator (no arguments here) and used flow_from_directory with shuffle = False.
  2. There are no augmentations nor preprocessing of 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() ie 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 :)

@petezurich Thanks for your comment. Generator.reset() before model.predict_generator() and turning off the shuffle in predict_generator() fixed the problem

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