NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Diffusion-based Layer-wise Semantic Reconstruction for Unsupervised Out-of-Distribution Detection

Ying Yang, De Cheng, Chaowei Fang, Yubiao Wang, Changzhe Jiao, Lechao Cheng, Nannan Wang, Xinbo Gao

Introduction

In real-world machine learning deployments, models must reliably identify samples that fall outside their training distribution—a task known as Out-of-Distribution (OOD) detection. Ideally, this is achieved in an unsupervised manner, where the model learns exclusively from unlabeled In-Distribution (ID) data.

Traditional reconstruction-based methods, such as Autoencoders (AEs) and Generative Adversarial Networks (GANs), often struggle with the "reconstruction dilemma": high-capacity models may inadvertently reconstruct OOD samples too well, while restricted models fail to capture ID diversity. While pixel-level diffusion models offer a potential solution, they are computationally intensive and often prioritize low-level textures over high-level semantics. This paper introduces DLSR (Diffusion-based Layer-wise Semantic Reconstruction), a framework that performs diffusion on multi-layer semantic features to achieve high-accuracy, high-speed OOD detection.

The DLSR Framework

DLSR shifts the reconstruction task from the pixel domain to the latent feature domain. The framework operates in three distinct stages:

  1. Multi-layer Semantic Feature Extraction: The model utilizes a pre-trained encoder (e.g., EfficientNet-b4) to extract feature maps from multiple hierarchical stages. These features are pooled and normalized to create a comprehensive "semantic fingerprint" of the input image.
  2. Diffusion-based Feature Reconstruction: The core component is the Latent Feature Diffusion Network (LFDN). During training, Gaussian noise is added to the ID features ($z_0 \to z_t$). The LFDN learns to reverse this process, reconstructing the original features. Because the network is trained only on ID distributions, it fails to accurately reconstruct the semantic features of OOD samples.
  3. OOD Detection Head: At inference, the model compares the original features with their reconstructions using metrics like Mean Squared Error (MSE), Likelihood Regret (LR), and a novel Multi-layer Semantic Feature Similarity (MFsim) based on cosine similarity.
Overview of the DLSR framework, illustrating the transition from pixel space to multi-layer semantic feature reconstruction.

Experimental Results and Efficiency

The researchers evaluated DLSR against standard benchmarks, using ID datasets like CIFAR-10 and CIFAR-100 and various OOD datasets including SVHN, MNIST, and Places365.

State-of-the-Art Accuracy

DLSR demonstrates exceptional discriminative power. On the CIFAR-10 benchmark, the method achieved an average AUROC of 99.7% using the MFsim metric. This performance significantly exceeds that of traditional pixel-level generative models like VAEs and DDPMs, as well as distance-based methods. By focusing on semantic layers rather than raw pixels, DLSR effectively ignores non-essential characteristics like sensor noise, leading to a clearer separation between ID and OOD data.

Massive Computational Speedup

A primary advantage of DLSR is its efficiency. Because the LFDN operates on low-dimensional feature vectors (e.g., dimension 720) rather than high-dimensional image grids, it is nearly 100 times faster than standard pixel-level diffusion models. As shown in the comparative analysis, DLSR processes approximately 999 images per second, compared to just 11.4 for the Denoising Diffusion Probabilistic Model (DDPM).

Comparison of DLSR against pixel-level generative models on CIFAR-10, highlighting superior AUROC and inference speed.

Conclusion

DLSR addresses the limitations of pixel-level reconstruction for OOD detection by leveraging the hierarchical semantic features of pre-trained encoders. By combining the robust distribution-modeling capabilities of diffusion networks with the efficiency of latent-space operations, DLSR provides a state-of-the-art solution that is both highly accurate and computationally practical for real-time applications. Future work may explore end-to-end optimization of the encoder and diffusion network or extend this semantic reconstruction approach to non-visual modalities.

Summary updated

BibTeX
@inproceedings{yang2024diffusion,
  author = {Ying Yang and De Cheng and Chaowei Fang and Yubiao Wang and Changzhe Jiao and Lechao Cheng and Nannan Wang and Xinbo Gao},
  title = {{Diffusion-based Layer-wise Semantic Reconstruction for Unsupervised Out-of-Distribution Detection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=3m5ndUNQYt},
}
Figure