Reputation: 263
I have 1000 images of dogs and 1000 images of cats.
I've trained a small CNN to do classification on this dataset and the accuracy on both the validation/test set is 99% +.
But, I've noticed that when I give an input that isn't a cat or a dog, for example a car, the classifier (sometimes) gives a high confidence of cat or dog.
Why is this? I understand that the CNN has only been trained on two classes, but if it sees something completely random shouldn't it output a low confidence for both classes?
I assume that this problem is solved by negative examples (of other random object and animals), but then the question becomes: how many negative examples are needed to truly cover the distribution of all the possible random images (that aren't of cats or dog)?
Upvotes: 1
Views: 1942
Reputation: 117
If the network is trained only on dog/cat images, it makes sense that it confuses an image that belongs to none of the two categories. You should add negative examples in the training set (as you mentioned) and convert your final classification layer to predict confidence over 3 catetegories (dog, cat, none). This should work better.
Upvotes: 2