2
$\begingroup$

I want to create a dog-classifier, which outputs the probability of an image containing a dog.

I have two approaches in mind -

  1. Binary classifier (1-class), which just outputs the probability of the image containing a dog. This seems reasonable to me.

  2. 2-class classifier with two classes denoting "dog" and "not-dog". But my problem with this approach is that the neural network has to learn the "not-dog" class as well, which is impossible since it has no pattern and is different in each training example.

Would the second approach be less effective than the first? Or even work at all?

Thank you.

$\endgroup$
0
$\begingroup$

tl;dr

The two approaches you mention are equally effective.

Why?

First of all, I'll assume you're referring to a neural-network-type model. You should note that Convolutional Neural Networks are discriminative models, meaning that they are trained to find the differences between two classes (e.g. dog and not-dog).

Would the second approach be less effective than the first?

Just to disprove this claim, consider the following. You have a 2-output classification network; let's name the outputs dog and not-dog. Now imagine, as you say, that the network can only identify dog patterns. All it would have to do was to give a positive weight to those patterns for the dog class and a negative weight for the not-dog class. In this sense the not-dog class would be trained as the opposite of the dog class, which would not make it less effective than a single-output binary classifier.

Even if the not-dog class could not be trained and remained constant, due to the fact that we're using a softmax activation, predictions would be generated just by the relative difference between the dog output and the constant not-dog output. This is exactly like having a single-output binary classifier.

$\endgroup$
1
$\begingroup$

You can use a anomaly detection autoencoder architecture. Basically, what you will do is,

  • Create an autoencoder architecture wih convolutional layers.

  • We train the model on images of dogs.

  • So when we feed a image of a dog on the trained autoencoder, it will produce a relatively small loss.

  • When a image other than a dog is fed to the model, the loss value will be high.

Thus, we can detect a presence of the dog in the image using the loss value.

$\endgroup$
0
$\begingroup$

Binary classification is 2-class classification. The difference you listed is actually between soft and hard classification. In soft classification you have a continuous distribution on all the classes, in hard classification the output is a one-hot encoded vector.

At some point, your model must be able to express some classification (either "dog" or "not-dog"), therefore you would end up with hard classification anyway.

$\endgroup$
0
$\begingroup$

Agree with Schubam's answer, treat this as an anomaly detection system, train only on dog images , and flag any image that has high loss as a non-dog image. and yes use 2 classes dog and not-dog, just like cancer detection.

$\endgroup$
0
$\begingroup$

The first and second approach is the same, as learning which images are not-dog is part of binary classification.

$\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.