Reputation: 327
I'm using MNIST example with 60000 training image and 10000 testing image. How do I find which of the 10000 testing image that has an incorrect classification/prediction?
Upvotes: 19
Views: 13201
Reputation: 147
Editing as was not clear earlier
To identify the image files that are wrongly classified, you can use:
fnames = test_generator.filenames ## fnames is all the filenames/samples used in testing
errors = np.where(y_pred != test_generator.classes)[0] ## misclassifications done on the test data where y_pred is the predicted values
for i in errors:
print(fnames[i])
Upvotes: 2
Reputation: 2116
Simply use model.predict_classes()
and compare the output with true labes. i.e:
incorrects = np.nonzero(model.predict_class(X_test).reshape((-1,)) != y_test)
to get indices of incorrect predictions
Upvotes: 24