For a research project, I am modeling parts of the human visual system using a VGG16 conv-net. A prominent feature of the visual system is that there are parts that only detect/classify certain categories of images (e.g. faces, text) and stay relatively silent for images not belonging to this category (not-face, not-text).

I'd like to train the model in such a way that it will classify, using a standard one-hot encoding scheme, different faces belonging to celebrities, but output all zeros (or all small values) for non-faces. Which training criterion should I use? Normally, I'd use cross-entropy for classifying faces, but how to incorporate wanting all zeros for training examples that are not faces?


1 Answer 1


You can add an extra class for non-face, still using cross-entropy.

Let's say you have four different celebrities that you want to recognize. Then create your model with five outputs. Let's say the first one corresponds to non-face. Training labels should be

0-0-0-1-0 or 0-1-0-0-0 for one of the celebrities, and 1-0-0-0-0 for a non face. Now you train your network with cross-entropy (on five outputs). Then a prediction from the network will result in for example

0.21-.38-.12-.52-.11 , this is prediction for the third celebrity, and a prediction of 0.91-0.12-0.23-0.23-0.11 corresponds to a prediction of a non-face.

This seems to a straightforward implementation of what you are looking for, using tools you already know.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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