I have a data set of 10,000 images of 5 different recycling items. The goal of my neural network is to tell me if an item is recyclable or not. The problem is that I only have data for the 5 different classifications (soda can, crushed soda can, water bottle, glass bottle, cardboard boxes). If you feed the trained network something that is not one of these 5 items (something like a plastic bag) it will still try to label it as one of these 5. Is there a way to logically separate out the garbage items without having data of the garbage. I don't have time to collect more data of garbage items and add a 6th classification to the neural network.


migrated from stackoverflow.com Aug 13 at 19:10

This question came from our site for professional and enthusiast programmers.


Yes, but it the most focused treatment takes a different approach. You need to choose a model type that will train each class on an "is or is-not". This is also called "one-vs-all". Your result will be, effectively, a separate set of weights for each of the five classes, five models that will decided whether or not the observation (one datum) is a member of that class. If none of the five sub-models claims the item, it winds up in the "garbage" class.

SVM (support vector machine) is good for this, given compatible input. There are more sophisticated treatments, but a discussion of those broadens beyond the typical scope of Stack Overflow.

  • $\begingroup$ Up-voted, but do you think one-vs-all would be an efficient/effective approach with neural networks as well (since the OP has mentioned that he/she is interested to use a NN)? $\endgroup$ – today Aug 13 at 18:39
  • $\begingroup$ This is part of the discussion I'm trying to avoid expanding. Yes, I feel that parallel (or "twin") models can nail this quite well: one model for yes/no on each class should do even better than SVM. $\endgroup$ – Prune Aug 13 at 18:45
  • $\begingroup$ Yeah, I understand your points. But I am also thinking about its efficiency/practicality: even if you do parallel training, would it be possible to do it in a reasonable amount of time? Especially considering the cases where we might have 100K+ training samples and 100+ classes. $\endgroup$ – today Aug 13 at 19:00
  • $\begingroup$ Now you can elaborate more (of course, if you would like to), because the question has been migrated. $\endgroup$ – today Aug 13 at 19:32

Yes, and this is called: one-class classification when you train a model only on the positive data and try to predict the outliers. check this it might help: https://medium.com/squad-engineering/one-class-classification-for-images-with-deep-features-69182fb4c9c5


I think you need to look at this problem in a different aspect. Based on your case, instead of training your model to recognize 'if this item is recyclable', you can approach this problem as 'if this item is not recyclable'. The reason is you only have 5 recyclable items, which is much less that those of in reality. So, by the way, you can look at this problem as an unsupervised learning way or a semi-supervised learning way, with the assumption that you have access to the items that are NOT recyclable. In detail, the suggested approaches are of two:

  1. unsupervised learning: design your problem as an outlier detection problem. Build the training information with most of non-recyclable item with very few recyclable item. Follow the approaches such as k-means clustering, Gaussian mixture model, etc.

  2. semi-supervised learning: in this one, you are doing a regression on only the non-recyclable item. If you provide a item that is recyclable to your trained model, your model will predicted a value with large deviation comparing with you predefined value. Please refer to one-class SVM or one-class neural network. In your subject, for image based detection, probably constitutional neural network will be better...


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.