Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Test Accuracy for model.predict_generator

Tags:

python

keras

I am calling model.predict_generator() method for predictions on Test data-set. My question is how can I retrieve test accuracy ? Following is my code line:

predictions = model.predict_generator(test_images, steps=3,  verbose=0)

Where test_iamges in the parameter of predict_generator function has batch data retrieved from local disk by calling ImageDataGenerator

Any guidance will be highly appreciated.

Thanks

like image 343
Pervaiz Niazi Avatar asked Aug 20 '18 21:08

Pervaiz Niazi


1 Answers

There is a corresponding function model.evaluate_generator that will give the loss, acc etc on your test set but not the predictions. Have a look at the model documentation, ex:

loss, acc = model.evaluate_generator(test_images, steps=3, verbose=0)

Returns: Scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics).

like image 130
nuric Avatar answered Oct 29 '22 05:10

nuric