Dual Representation Learning for Out-of-Distribution Detection

Zhilin Zhao, Longbing Cao

TL;DR

Dual Representation Learning (DRL) tackles the over-confidence problem in out-of-distribution (OOD) detection by capturing both strongly and weakly label-related features of in-distribution data. By pairing a standard pretrained network with an auxiliary network that focuses on discarded, distribution-sensitive details, DRL creates a consistency check that successfully flags OOD samples.

What Problem Does This Paper Address?

Deep neural networks are notoriously overconfident when facing data they have never seen before—known as Out-of-Distribution (OOD) data. According to the Information Bottleneck principle, standard networks compress input data to keep only the most strongly label-related information needed for classification, discarding everything else.

For instance, a network trained to classify dogs might only focus on the head. If it encounters an OOD image containing a drawing of a dog's head on a backpack, the network will confidently classify it as a "dog." The authors address this vulnerability by recovering the discarded, "weakly label-related" information (like the dog's body or contextual features) to reliably distinguish between In-Distribution (ID) and OOD samples.

Figure 1: Different informativeness properties of ID and OOD samples. Red and yellow boxes capture the information for learning label- and distribution-discriminative representation, respectively. The label- and distribution-discriminative representations of the ID sample correspond to the same label (dog). Conversely, the label- and distribution-discriminative representations of the OOD sample correspond to different labels (dog and bag). However, the OOD sample is assigned with a high-confidence prediction for the wrong label (dog) since it obtains minimum strongly label-related information about the label. It causes networks cannot distinguish between ID and OOD samples.

Methods

The authors propose Dual Representation Learning (DRL). Instead of modifying or retraining the original pretrained network (which extracts label-discriminative representations, $d$), they introduce a dependent auxiliary network ($f_\theta$).

  1. Auxiliary Training: The auxiliary network is trained to find distribution-discriminative representations ($c$) from the weakly label-related information left behind by the primary network.
  2. Implicit Constraint: To ensure $c$ captures different information than $d$, the authors decompose $c$ into a linear combination of diverse component representations ($z$). Components that are less similar to the primary representation $d$ are automatically assigned higher weights ($w$).
  3. OOD Scoring: During the test phase, the softmax outputs of both networks are averaged. For an ID sample, both representations point to the same label (high consistency). For an OOD sample, the primary and auxiliary representations conflict, lowering the final confidence score and exposing the sample as out-of-distribution.
Figure 2: The DRL learning process. It includes: (i) learning a pretrained network on training ID samples for label-discriminative representations; (ii) learning an auxiliary network on training ID samples and their corresponding label-discriminative representations for distribution-discriminative representations; and (iii) calculating the OOD scores by combining these two representations.
Figure 3: Constructing a distribution-discriminative representation. A thicker black line indicates a larger weight or vice versa. A distribution-discriminative representation consists of multiple component represen- tations where a component representation less similar to the label-discriminative representation is given a higher weight.

Datasets

The method was evaluated using standard image classification setups:

  • In-Distribution (ID) Datasets: CIFAR10 (10 classes) and Mini-ImageNet (100 classes).
  • Out-of-Distribution (OOD) Datasets: CIFAR100, CUB200, StanfordDogs120, OxfordPets37, Oxfordflowers102, Caltech256, DTD47, and COCO.

Key Insights and Ideas

  • The Discarded Info is Useful: Standard classification networks throw away background and contextual data because it isn't strictly needed to minimize training loss. However, this discarded data is exactly what defines the distribution of the data.
  • Consistency as a Shield: For true in-distribution data, primary features (e.g., a dog's head) and secondary features (e.g., a dog's body) naturally co-occur and point to the same class label. OOD samples break this harmony, creating an "inconsistency" that DRL easily measures.
  • Calibration Bonus: Beyond detecting OOD samples, combining both representations drastically improves the model's calibration (reducing Expected Calibration Error), making its confidence scores much more trustworthy overall.

Key Results

  • State-of-the-Art Performance: DRL consistently outperforms existing post-hoc and confidence enhancement methods across diverse OOD datasets.
  • AUROC Improvements: When trained on CIFAR10, DRL achieved an average AUROC of 81.9% (outperforming the baseline's 78.7%). On Mini-ImageNet, DRL achieved an average AUROC of 76.9% (outperforming the baseline's 75.2%).
  • Better Calibration: On CIFAR10, the Expected Calibration Error (ECE) dropped significantly from 2.85% (using the primary network alone) to 1.26% when deploying the combined DRL model.

Limitations and Future Work

  • Computational Overhead: DRL requires training and running an extra auxiliary network alongside the pretrained model, which increases the computational and memory footprint.
  • Information Dependency: If the training ID dataset contains very little label-related information or is dominated by noise, the auxiliary network won't have enough meaningful "weakly label-related" information left to extract.
  • Future Directions: The authors suggest exploring data augmentation techniques to bake OOD-sensitive information directly into a single network during finetuning, potentially eliminating the need for a separate auxiliary model.

Summary updated

Abstract

To classify in-distribution samples, deep neural networks explore strongly label-related information and discard weakly label-related information according to the information bottleneck. Out-of-distribution samples drawn from distributions differing from that of in-distribution samples could be assigned with unexpected high-confidence predictions because they could obtain minimum strongly label-related information. To distinguish in- and out-of-distribution samples, Dual Representation Learning (DRL) makes out-of-distribution samples harder to have high-confidence predictions by exploring both strongly and weakly label-related information from in-distribution samples. For a pretrained network exploring strongly label-related information to learn label-discriminative representations, DRL trains its auxiliary network exploring the remaining weakly label-related information to learn distribution-discriminative representations. Specifically, for a label-discriminative representation, DRL constructs its complementary distribution-discriminative representation by integrating diverse representations less similar to the label-discriminative representation. Accordingly, DRL combines label- and distribution-discriminative representations to detect out-of-distribution samples. Experiments show that DRL outperforms the state-of-the-art methods for out-of-distribution detection.
BibTeX
@article{zhao2023dual,
  author = {Zhilin Zhao and Longbing Cao},
  title = {{Dual Representation Learning for Out-of-Distribution Detection}},
  journal = {Accepted by TMLR},
  year = {2023},
  url = {https://openreview.net/forum?id=PHAr3q49h6},
}
Figure