Javier Vargas Javier Vargas - 1 month ago 21
Python Question

Tensorflow Image Classification Script

So I am quite new in TensorFlow .

I followed all the CodeLab of TensorFlow For Poets, I trained the model using only Daisies and Roses.

Then I used the label_image.py script to test and classify images.
https://gist.githubusercontent.com/wolffg/541c97a74dfc0d77c4b8fd2a946a5b41/raw/578853dd26180dbf5bfc66eb40fdd13fb3aba4d6/TensorFlow%2520codelab

But when I tried with random images that have no roses or daisies I still get a high score.

How can I modify that script or if you know any other script that it can tell me like if there is a Rose or a Daisy or Nothing there.

Answer

Softmax will encourage the network to make a decision so you'll usually end up with something.

As Luis said, you can add an "unknown" class to your categories. This is probably the simplest option :)

As the softmax outputs are probabilities, you could also try setting a threshold where anything with a low enough score is considered a no-result, though as above, softmax is a good decision-maker, so it may not work too well.

Since you're using a two-class prediction, another option is to replace softmax with a sigmoid function to get an output between 0 (e.g. roses) and 1 (e.g. daisies). You could then pick a range in the middle (e.g. 0.4-0.6) that you consider uncertain and use that as your "unknown" label.

Comments