A Systematic Comparison of Training Objectives for Out-of-Distribution Detection in Image Classification

This paper systematically evaluates four training objectives—Cross-Entropy, Prototype, Triplet, and Average Precision Losses—for out-of-distribution detection in image classification, revealing that while they achieve comparable in-distribution accuracy, Cross-Entropy Loss delivers the most consistent performance across both near- and far-OOD scenarios under standardized protocols.

Furkan Genç, Onat Özdemir, Emre Akbas

Published 2026-03-10
📖 5 min read🧠 Deep dive

Imagine you are hiring a security guard for a high-stakes building, like a hospital or a bank. You train this guard to recognize specific people: doctors, nurses, and patients (these are your In-Distribution or ID data).

But in the real world, the guard will eventually see strangers: delivery drivers, tourists, or even someone in a costume (these are Out-of-Distribution or OOD data).

The big problem is: How do you train the guard so they don't just guess who is who, but also know when to say, "I have no idea who you are, and that's suspicious"?

This paper is a systematic test to see which training method (or "coaching style") creates the best guard. The authors tested four different ways to teach the model, using standard datasets like CIFAR (small images) and ImageNet (complex images).

Here is a breakdown of the four "coaching styles" they compared, using simple analogies:

1. The "Standard Teacher" (Cross-Entropy Loss)

  • The Analogy: This is the traditional teacher who says, "Memorize the faces of the doctors and nurses. If you see someone, pick the name that feels most familiar."
  • How it works: It focuses purely on getting the right answer for known people. It doesn't explicitly teach the guard to measure how different a stranger looks; it just relies on the fact that strangers won't look exactly like the doctors.
  • The Result: This was the most consistent performer. It didn't always win every single category, but it was reliable. It knew the doctors well, and when a stranger walked in, it was usually the most honest about being unsure. It's the "safe bet" that works everywhere.

2. The "Distance Coach" (Triplet Loss)

  • The Analogy: This coach is obsessed with geometry. They say, "Stand next to your friend (same class), but stand as far away as possible from the person in the red hat (different class)."
  • How it works: It tries to create a map where similar things are clustered tightly together and different things are pushed far apart.
  • The Result: This worked okay for small groups (like CIFAR-10), but it crumbled under pressure when the group got huge (like ImageNet with 200 classes). Imagine trying to organize a stadium of 200 different teams by telling them to stand far apart from everyone else; it gets messy and confusing. The guard got confused about who the "real" doctors were, leading to poor performance.

3. The "Prototype Mentor" (Prototype Loss)

  • The Analogy: This mentor says, "Don't memorize every single face. Instead, create a perfect 'average' face for a doctor and a perfect 'average' face for a nurse. Measure how close a new person is to these perfect averages."
  • How it works: It creates a central "ideal" for each category and measures distance to that ideal.
  • The Result: This was great at identifying the known people (high accuracy). The guard became very good at spotting a doctor. However, when a stranger walked in, this method wasn't always better at flagging them as suspicious compared to the "Standard Teacher." It's a great classifier, but not necessarily the best detector of the unknown.

4. The "Ranking Referee" (Average Precision Loss)

  • The Analogy: This referee doesn't care about the exact score; they care about the order. They say, "Make sure the 'Doctor' score is always higher than the 'Stranger' score, and the 'Nurse' score is higher than the 'Stranger' score."
  • How it works: It focuses on ranking the correct answer at the top of the list, rather than just getting the probability right.
  • The Result: This was a strong contender. In some tests, it was even better at spotting strangers than the Standard Teacher. However, it was a bit inconsistent; sometimes it was great, other times it struggled to keep the known people perfectly identified.

The Big Takeaway

The authors ran these tests on three different "training grounds" (datasets) of increasing difficulty. Here is what they found:

  1. The "Standard Teacher" (Cross-Entropy) is the MVP.
    Despite all the fancy new methods, the old-school way of training is still the most reliable. It balances knowing the "good guys" well and spotting the "bad guys" (strangers) consistently, especially in large, complex environments.

  2. Specialized methods have a trade-off.

    • Triplet Loss (Distance) gets too confused when there are too many classes.
    • Prototype Loss (Averages) is great at knowing the "good guys" but doesn't always catch the strangers better than the standard method.
    • AP Loss (Ranking) is promising but can be a bit hit-or-miss depending on the dataset.
  3. The "Stranger" is harder to catch when they look familiar.
    The paper also noted that it's much easier to spot a stranger who looks totally different (like a cat when you trained on dogs) than a stranger who looks almost like a dog (like a wolf). All methods struggled more with the "almost" strangers, but the Standard Teacher handled it best overall.

In a Nutshell

If you are building a safety system for a real-world application, don't get distracted by the flashiest new training tricks yet. The paper suggests that the classic Cross-Entropy Loss is still the most robust, reliable, and scalable choice for detecting when your AI is seeing something it doesn't understand. It's the "Swiss Army Knife" of training objectives: it might not be the sharpest knife for one specific job, but it's the best tool to have in your pocket for everything else.