7
$\begingroup$

For example I need to detect classes for MNIST data. But I want to have not 10 classes for digits but also I want to have 11th class "not a digit". So that any letter (except "O" of course:) ), any other type of image or random noise would be classified as "not a digit".

Or with CIFAR-10 I want to have 11th "unknown" class to classify any image that contain something out of classes range.

So how to implement such feature? Maybe there are some examples somewhere, preferable with Keras.

$\endgroup$
3
$\begingroup$

The usual way to implement this would be to add the new class with data examples.

Some things you need to address:

  • Sourcing new data for your "other" class.

  • Ensuring the amount and variation of data in "other" class examples matches how the predictor will be used.

Code examples for this are not necessary, as you would just use the same network design as you already have and just add another output. This is a data and model definition problem.

Logically you have another option: As well as outputting the predicted class, you predict separately whether there is any detectable object at all as a true/false value. This still requires the additional data, but is for example how the YOLO algorithm works for object detection. Object detection has a specific meaning - it involves finding the co-ordinates and class of possibly multiple objects in an image. This goes beyond the wording of your question, but is a typical end goal if you are asking this kind of question.

YOLO predicts the presence of an object separately from the class of object. The additional data for YOLO training comes from segmenting the source images, so many parts of the target image are background with no objects. In that case the additional data you require is due to more detailed labelling within each image example.

YOLO is quite complicated architecture, so you might want to look at this example using Keras on a Github project for more details, if object detection is your goal.

$\endgroup$
  • $\begingroup$ "As well as outputting the predicted class, you predict separately whether there is any detectable object at all as a true/false value." Thanks for this! Combining this as a first step to my existing model has decreased the noise significantly! $\endgroup$ – flakes Dec 21 '18 at 11:12
1
$\begingroup$

If you are using a softmax distribution for your classification, then you could determine what your baseline max probability is for correctly classified samples, and then infer if a new sample doesn't belong to any of your known classes if its max probability is below some kind of threshold.

This idea comes from a research paper that does a much better job of explaining the process than what I just said: A Baseline for Detecting Misclassified and Out-of-Distribution Examples in Neural Networks

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.