arXiv:2611.07580cs.CVNov 2026

Manuscript Offprint

arXiv:2611.07580

Subspace Learning with Outlier Exposure for Out-of-Distribution Detection

Hongxu Shen, Kun Fang, Jiahui Zheng, Jian Sun, Qinghua Tao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Out-of-Distribution (OoD) detection is pivotal for reliable deployments of Deep Neural Networks (DNNs), aiming to distinguish anomalous samples from the In-Distribution (InD) data in training. By introducing outliers as surrogate OoD data to finetune DNNs, Outlier Exposure (OE) has greatly advanced OoD detection in recent years. Existing OE-based research remains predominantly logit-centric, either by generating diverse outliers or by regularizing them with objectives operating at the prediction-output level. Nonetheless, these approaches leave much of the rich information in feature spaces untapped. In this work, we propose an OE-based detection framework, named RecOE, that learns appropriate feature subspaces from InD data and auxiliary outliers, such that the InD-OoD discrepancy can be effectively characterized through the learned feature subspaces. Specifically, the feature subspaces are optimized to capture the dominant variations of InD and outliers by minimizing reconstruction errors therein. Besides, a sample-level objective discourages reconstruction in the opposing subspace, while an orthogonality regularizer reduces subspace overlap, further promoting discriminative subspaces. At inference, the difference in reconstruction errors between the learned subspaces serves as the OoD detection score. Extensive experiments show the superiority of RecOE on multiple benchmarks, in which significant

*Corresponding author.

Email addresses: shenhongxu@bit.edu.cn (Hongxu Shen), kun.fang@polyu.edu.hk (Kun Fang), zhengjh14@tsinghua.org.cn (Jiahui Zheng), sunjian@bit.edu.cn (Jian Sun), qinghua.tao@bit.edu.cn (Qinghua Tao)

1^{1}These authors contributed equally to this work.

performance gains are achieved over recent strong baselines with only slight extra overhead from two small-size matrices of subspace bases. The source code is available at https://github.com/shenhongxu123/RecOE.

Keywords: Out-of-distribution detection, outlier exposure, principal component analysis, subspace learning

1. Introduction

While deep neural networks (DNNs) have achieved vast success in real-world applications [1, 2], they are known to yield overconfident predictions on samples that deviate from the in-distribution (InD) training data [3], commonly known as Out-of-Distribution (OoD) samples. Such behavior poses substantial risks in safety-critical scenarios, including autonomous driving, medical diagnosis, and financial systems [4], making OoD detection a crucial research problem.

Existing OoD detection methods can be broadly categorized according to whether they require finetuning of a DNN. A series of post-hoc methods [5, 6, 7, 8, 9, 10, 11, 12] have been proposed with the main idea of leveraging the responses from a pretrained model to devise detection scores that capture the InD-OoD discrepancy. Another line of research introduces outliers as surrogate OoD data to finetune the DNN with regularization terms, which effectively promotes detection performance, known as Outlier Exposure (OE) [13]. OE-based methods advance OoD detection in two main aspects: outlier construction and outlier regularization. The former improves auxiliary outliers to provide surrogate OoD supervision through boundary-aware mining [14, 15], ID-outlier mixing [16], and informative extrapolation [17]. The latter develops regularization objectives to finetune the DNN for enhanced InD-outlier separation via energy-based margin regularization [6], gradient regularization of the OoD score function [18], or feature-based geometric constraints [19, 20]. Our work falls into the outlier-regularization category.

Early OE methods rely on the output logit space for both outlier generation and regularization [19]. The logit layer in DNNs primarily encodes coarse-grained knowledge associated with predictive classification probabilities. In contrast, feature spaces of DNNs encode far richer and structured information of data distributions, including hierarchical representations, geometric patterns, and semantics learned across layers. Recent feature-based OE methods promote InD-OoD separation using geometric references de-rived from classifier weights [19] or predefined structures [20]. Please find a detailed discussion in Section 2.1.

In this work, we propose RecOE, an OE-based OoD detection framework that exploits InD-OoD discrepancy through optimizing low-dimensional feature subspaces. We posit that distribution-associated dominant directions of feature variation provide useful structure for distinguishing InD data from outliers. Accordingly, we construct and optimize an InD-associated subspace and an auxiliary-outlier-associated subspace spanned by learnable orthonormal bases UinU_{\mathrm{in}} and UauxU_{\mathrm{aux}}, respectively. As commonly in OE-based detection, auxiliary outliers serve as a surrogate non-InD reference when the open-world OoD distribution is unavailable during training. The subspace spanned by UauxU_{\mathrm{aux}} therefore characterizes the structures exposed by these auxiliary training outliers, providing an important reference basis for separating InD data from OoD data.

In our RecOE framework, each subspace is constructed to capture the dominant variations of its corresponding feature distribution while those two subspaces are regularized to remain separated from each other. To this end, we jointly optimize the subspaces and the backbone, allowing the feature representations to adapt to the fitting and separation objectives. We therefore formulate two complementary learning objectives, subspace fitting and subspace separation, detailed as follows.

  • Subspace Fitting. Along with Principal Component Analysis (PCA) [21], we optimize UinU_{\mathrm{in}} and UauxU_{\mathrm{aux}} by minimizing the reconstruction error of training samples on UinU_{\mathrm{in}} and that of outliers on UauxU_{\mathrm{aux}}, such that UinU_{\mathrm{in}} captures intrinsic InD patterns and UauxU_{\mathrm{aux}} maximally describes the outliers to characterize the potential OoD.

  • Subspace Separation. The separation between the two subspaces is optimized at both sample and parameter levels. At the sample level, we deploy the margin-based hinge loss to encourage InD features with large reconstruction errors on the subspace UauxU_{\mathrm{aux}}, similarly for outlier features on UinU_{\mathrm{in}}. This ensures UinU_{\mathrm{in}} and UauxU_{\mathrm{aux}} to retain minimal information from the opposing distribution. At the parameter level, an orthogonality regularizer is imposed to disentangle the two subspaces UinU_{\mathrm{in}} and UauxU_{\mathrm{aux}}.

Notably in optimization, rather than solving an eigenvalue problem in standard PCA, the orthonormal bases can be optimized on Stiefel manifold [22] with Riemannian Adam optimizer [23, 24]. Thus, RecOE flexibly

Figure

Figure 1: Experimental exemplification on the effectiveness of RecOE, with CIFAR-10 as InD and iSUN as OoD. We interpolate the distribution of (a) reconstruction errors from a standard PCA on the pretrained DNN and (b) reconstruction contrast score by RecOE.

adapts to the end-to-end manner under OE-based training framework for OoD detection. We further introduce progressive-rank optimization to capture dominant feature variations at low rank before gradually expanding the subspaces to the target rank. This helps reduce interference from poorly estimated directions during early training.

The two optimized subspaces yield contrasting reconstructions of InD and OoD features. Specifically, InD samples are expected to be well reconstructed by UinU_{in} and poorly reconstructed by UauxU_{aux}, whereas OoD samples tend to exhibit the opposite behavior. We use the difference between the two reconstruction errors as an effective detection score, as illustrated in Figure 1.

Our main contributions are summarized as follows.

We introduce a feature-subspace perspective for OE regularization, revealing that intrinsic low-dimensional structures of InD and outlier features provide promising discriminative supervision for OoD detection.

We propose RecOE, a new framework that learns distribution-specific feature structures with InD-OoD separability in the subspaces. By fitting each subspace to its own distribution and suppressing information from the opposite one, their relative reconstruction naturally leads to a discriminative detection score. We introduce progressive-rank opti-mization to prioritize dominant feature variations early in training.

  • Extensive experimental results validate the superiority of RecOE with state-of-the-art performance gains at only slight extra overhead from two small-size matrices.

References (40)