9

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.

Ada Stra
  • 1,501
  • 3
  • 13
  • 14

1 Answers1

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)
Daniel Möller
  • 84,878
  • 18
  • 192
  • 214
  • 1
    thank you, of course! Amazing how it's always obvious once explained ... – Ada Stra Jun 24 '17 at 22:54
  • @Daniel Möller What is trainingClasses here ? or Is it a list or something else ? – WaterRocket8236 Jan 30 '18 at 13:40
  • It's `y_train` as they usually name it. Your true labels, true target data, true results, etc. – Daniel Möller Jan 30 '18 at 14:04
  • and how can we, from this, get information about a single value? `result` in this case is an array of an array of numbers... – Aristides Jun 14 '18 at 14:29
  • 1
    @Aristides, get slices or elements from the array as you would normally: `sample0 = result[0]`, `sample1 = result[1]`. – Daniel Möller Jun 14 '18 at 15:02
  • 1
    @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? – Aristides Jun 15 '18 at 14:41
  • @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 users – NeStack Mar 19 '19 at 12:17