Image classification with Keras on Tensorflow: how to find which images are misclassified during training?
Asked Answered
H

1

11

I use Keras 2.0 (TensorFlow backend) on Ubuntu 17.04 to do binary image classification. Everything works great except I'd like to see which images are misclassified. How do I do that?

Also, unsure if it'd answer my problem, but in TensorBoard I can't get the image tab to work, so don't know if that'd help.

I've done a lot of googling, of course, but I just can't find an answer.

Halfwitted answered 24/6, 2017 at 20:1 Comment(0)
T
9

Simply predict the classifications and compare with your true values...

predicted = model.predict(trainingImages)    

Subtracting and removing the sign should result in near zero results for the right ones and high results for the wrong ones:

result = numpy.absolute(trainingClasses-predicted)
Tacye answered 24/6, 2017 at 20:12 Comment(7)
thank you, of course! Amazing how it's always obvious once explained ...Halfwitted
@Daniel Möller What is trainingClasses here ? or Is it a list or something else ?Feeney
It's y_train as they usually name it. Your true labels, true target data, true results, etc.Terzas
and how can we, from this, get information about a single value? result in this case is an array of an array of numbers...Sitka
@Aristides, get slices or elements from the array as you would normally: sample0 = result[0], sample1 = result[1].Terzas
@DanielMöller right so then I have to iterate over every single element, and check which ones have any result-of-subtraction above a certain threshold right? Is there any way to en-masse get all of the elements that were predicted incorrectly, and the information associated? For example, if we're doing image classification, how can I get the filepath of a single image or something along those lines?Sitka
@DanielMöller I think your second comment here is very important and should be included into the answer of the question, to be more visible for other usersWindcheater

© 2022 - 2024 — McMap. All rights reserved.