Detecting Out-of-distribution Examples via Class-conditional Impressions Reappearing

Jinggang Chen, Xiaoyang Qu, Junjie Li, Jianzong Wang, Jiguang Wan, Jing Xiao

Abstract

Out-of-distribution (OOD) detection is critical for the safe deployment of machine learning models, yet most state-of-the-art methods rely on access to original training data or specific OOD examples for parameter tuning. In many real-world scenarios, privacy regulations and proprietary restrictions make such data inaccessible. This paper introduces Class-Conditional Impressions Reappearing (C2IR), a novel "data-free" OOD detection framework. C2IR leverages model inversion to synthesize class-specific "impressions" from a fixed neural network, recovers internal statistics, and employs a gradient-based weighting scheme to identify anomalous inputs. Experimental results on ResNet34 architectures demonstrate that C2IR significantly outperforms standard post-hoc detection techniques, achieving an average AUROC of 97.48% across multiple OOD benchmarks.

1. Introduction

In a robust machine learning pipeline, a classifier should not only categorize known inputs accurately but also identify when a test sample falls outside its training distribution. While OOD detection has seen significant progress, a major bottleneck remains: the "data-hungry" nature of existing solutions. Many methods require the original in-distribution (ID) training set to establish baseline statistics or use auxiliary OOD datasets to tune hyperparameters.

In practice, researchers often operate under a "data-free" constraint due to regulations like GDPR or corporate security policies. When only the weights and architecture of a pretrained model are available, traditional OOD detection methods often falter. C2IR addresses this gap by treating the pretrained model as its own data source, extracting "impressions" of the training data to build a reliable detector without ever seeing the original images.

2. The C2IR Framework

The C2IR method operates through a three-stage pipeline designed to reconstruct the model's internal understanding of the world and use that understanding to flag anomalies.

2.1 Data Recovering via Model Inversion

Since the original training data is unavailable, C2IR "hallucinates" synthetic representatives for each class. Starting with random noise, the method uses model inversion to optimize the noise until it matches the mean and variance statistics stored within the model’s Batch Normalization (BN) layers. These synthetic images, termed "impressions," serve as proxies for the original training distribution. The authors observe that these impressions actually provide statistics closer to natural data than the raw running averages stored in BN layers.

2.2 Layer-wise Deviation Scoring

Once the impressions are generated, the system establishes a baseline for "normal" behavior at various layers of the network. For a given test input, the model calculates the internal activations across multiple layers. It then measures how much these activations deviate from the average activations of the synthetic impressions corresponding to the predicted class. This discrepancy is quantified using Integral Probability Metrics (IPM), providing a layer-by-layer anomaly score.

2.3 Measuring Gradient-based Importance (MGI)

Not all layers in a deep neural network are equally effective at distinguishing between ID and OOD data. Typically, layer weights are determined using a validation set. In the data-free setting, C2IR introduces Measuring Gradient-based Importance (MGI). By observing the gradients during the image synthesis process, the method identifies which layers are most sensitive during the "evolution" of a synthetic image. Layers that undergo significant activation changes to form a recognizable class impression are deemed more discriminative and are assigned higher weights in the final OOD score calculation.

3. Experimental Evaluation

3.1 Setup

The researchers evaluated C2IR using a ResNet34 base model trained on CIFAR10 as the In-Distribution (ID) dataset. To test the robustness of the detector, they utilized a diverse suite of Out-of-Distribution (OOD) datasets, including:

  • Near-OOD: CIFAR100.
  • Far-OOD: SVHN (digits), TinyImageNet, iSUN, and LSUN.

C2IR was compared against standard post-hoc methods that do not require OOD data for tuning, such as the Softmax Confidence Score, ODIN, and Energy-Based Models (EBM).

3.2 Results

C2IR demonstrated substantial performance gains over existing post-hoc baselines:

  • AUROC Performance: C2IR achieved an average 97.48% AUROC across seven OOD datasets, significantly higher than the Energy-Based Method (94.78%) and ODIN (90.36%).
  • TNR at 95% TPR: The True Negative Rate (TNR) showed an average improvement of +14.94% over the best-performing baseline, indicating a much lower false-alarm rate for OOD samples.
  • Far-OOD Success: The method was exceptionally effective at distinguishing radically different distributions, such as SVHN digits from CIFAR10 objects, reaching a near-perfect 98.81% AUROC.

4. Discussion and Conclusion

The success of C2IR highlights two critical insights. First, BatchNorm layers act as a "statistical diary" of the training data, retaining enough information to reconstruct the distribution's "ghost" even when raw images are deleted. Second, the process of data synthesis itself can serve as a proxy for feature importance, allowing for effective layer weighting without a validation set.

Despite its performance, C2IR faces challenges regarding computational overhead. Synthesizing thousands of virtual samples per class is more resource-intensive than simple forward-pass methods. However, this preparation is a one-time cost per model. Future work may explore more efficient synthesis techniques or the application of this "impression" reappearing technique to continual learning, where models must retain knowledge of old classes without storing original data.

Summary updated

Abstract

Out-of-distribution (OOD) detection aims at enhancing standard deep neural networks to distinguish anomalous inputs from original training data. Previous progress has introduced various approaches where the in-distribution training data and even several OOD examples are prerequisites. However, due to privacy and security, auxiliary data tends to be impractical in a real-world scenario. In this paper, we propose a data-free method without training on natural data, called Class-Conditional Impressions Reappearing (C2IR), which utilizes image impressions from the fixed model to recover class-conditional feature statistics. Based on that, we introduce Integral Probability Metrics to estimate layer-wise class-conditional deviations and obtain layer weights by Measuring Gradient-based Importance (MGI). The experiments verify the effectiveness of our method and indicate that C2IR outperforms other post-hoc methods and reaches comparable performance to the full access (ID and OOD) detection method, especially in the far-OOD dataset (SVHN).
BibTeX
@inproceedings{chen2023detecting,
  author = {Jinggang Chen and Xiaoyang Qu and Junjie Li and Jianzong Wang and Jiguang Wan and Jing Xiao},
  title = {{Detecting Out-of-distribution Examples via Class-conditional Impressions Reappearing}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=1Ec9fBWc-pv},
}
Figure