Manuscript Offprint
arXiv:2610.33909Rank-1 Weight-Corrected Trainable Weight Averaging for Out-of-Distribution Detection
Akito Shinohara and Hiroaki Aizawa
Graduate School of Advanced Science and Engineering,
Hiroshima University, Japan
{m252486,hiroaki-aizawa}@hiroshima-u.ac.jp
Abstract. Out-of-distribution (OOD) detection identifies inputs outside the training distribution. Rank-based analyses such as RankFeat and RankWeight suggest that OOD overconfidence is closely related to dominant low-rank components in feature and weight spaces. Since weight averaging operates directly in parameter space and improves model generalization, we consider it for OOD detection from a dominant-component perspective. Trainable Weight Averaging (TWA) assigns a single coefficient to each checkpoint, limiting independent control of dominant weight components. We extend TWA with leading rank-one weight components extracted by Singular Value Decomposition as correction directions, whose contributions are learned through the in-distribution classification objective. On ResNet50, our method improves over fine-tuning and standard TWA across the evaluated datasets with MSP and RankWeight, both with and without Outlier Exposure. Mahalanobis-based evaluation yields mixed results, indicating that the benefit depends on the OOD scoring protocol. Target-layer analyses with MSP and Energy favor correction near the classifier.
Keywords: Out-of-Distribution Detection · Trainable Weight Averaging · Subspace Optimization
1 Introduction
Reliable prediction requires models to maintain discriminative performance on known classes while identifying unknown data at test time. In real-world environments, deep neural networks often encounter inputs that are not represented in the training distribution. Such inputs can induce overconfident predictions even when they do not belong to any known class, which is problematic in safety-critical applications. Out-of-distribution (OOD) detection addresses this problem by determining whether an input lies outside the training distribution.
A broad range of OOD detection methods has been developed using model outputs or intermediate representations. Post-hoc scoring methods, such as Maximum Softmax Probability (MSP) [6] and Energy Score [13], use confidence or
A. Shinohara and H. Aizawa
logit-derived scores to separate in-distribution (ID) and OOD samples. Feature-space methods, such as Mahalanobis Distance [11] and ReAct [17], exploit statistical properties of learned representations. In addition to these post-hoc scoring and feature-level perspectives, recent rank-based analyses such as RankFeat and RankWeight [16] suggest that dominant low-rank components in feature and weight spaces are closely related to OOD behavior and model performance. These findings indicate that OOD overconfidence is not only a property of output scores, but is also linked to the geometry of representations and model parameters.
This parameter-space perspective naturally connects to weight averaging methods. Weight averaging has been widely studied as a way to improve generalization by operating directly on model parameters, including Stochastic Weight Averaging (SWA) [9], Model Soup [18], SWAD [1], and Trainable Weight Averaging (TWA) [12]. Among these methods, TWA learns averaging coefficients in a subspace spanned by candidate weights, providing a natural parameter-space mechanism for optimizing combinations of checkpoints. However, standard TWA assigns a single coefficient to each checkpoint. As a result, dominant low-rank weight components and the remaining checkpoint parameters are controlled together, making it difficult to adjust components that may contribute to OOD overconfidence without also changing components useful for ID classification.
Motivated by this limitation, we propose a dominant-component-aware extension of TWA. For each checkpoint, we apply Singular Value Decomposition (SVD) to selected weight matrices, extract the leading rank-one component, and introduce the resulting correction direction into the TWA subspace. The correction magnitude is learned with the ID classification objective, enabling adaptive control of dominant weight components without hard removal, architectural modification, or inference-time overhead. Since the proposed method operates in weight space, it can also be combined with data-driven OOD regularization such as Outlier Exposure (OE) [7]. We evaluate the proposed method on OOD detection tasks and compare it with conventional fine-tuning and standard TWA. We further analyze checkpoint ranges, target layers for the correction, compatibility with OE, and backbone architectures to clarify when dominant-component control is effective.
The main contributions of this work are summarized as follows:
– We propose a dominant-component-aware extension of TWA that augments the trainable weight subspace with correction directions derived from leading rank-one weight components.
– We enable independent control of dominant weight components and residual checkpoint components while retaining the standard inference cost and network architecture.
– We demonstrate improvements over fine-tuning and standard TWA with MSP and RankWeight on ResNet50, both with and without OE, while identifying mixed results with Mahalanobis scoring. Target-layer analyses with MSP and Energy show the strongest performance when correction is applied to the final classification layer.
Weight averaging is a parameter-space approach for improving generalization and robustness. Stochastic Weight Averaging (SWA) [9] averages checkpoints collected during training, Model Soups [18] merge independently trained models, SWAD [1] searches for flatter solutions, and Trainable Weight Averaging (TWA) [12] learns averaging coefficients in a subspace spanned by candidate weights. Separately, rank-based analyses have shown that dominant spectral components are closely related to OOD behavior: RankFeat [16] reports dominant rank-one components in OOD feature representations, and RankWeight [16] shows that controlling dominant low-rank components in weight matrices can improve model performance. However, standard TWA controls each checkpoint with a single coefficient and does not separately adjust such dominant weight components. Our method addresses this gap by augmenting the TWA subspace with correction directions derived from leading rank-one weight components.
3 Proposed Method
This section presents our dominant-component-aware extension of TWA, whose goal is to improve OOD detection by adaptively controlling dominant weight components. The key idea is to augment the TWA search subspace with correction directions extracted from leading rank-one checkpoint components, as summarized in Section 3.2. We first motivate this design in Section 3.1, then describe the formulation, component extraction, subspace optimization, and adaptive-control interpretation in Sections 3.2, 3.3, 3.4, and 3.5, respectively.
3.1 Motivation
RankWeight reports that the rank-one component associated with the largest singular value of a weight matrix can contribute more strongly to overconfident OOD predictions than to ID classification performance [16]. A direct way to use this observation is to remove the dominant component from the weight matrix. However, such hard removal may also discard information that is useful for classifying ID samples.
A. Shinohara and H. Aizawa

Fig. 1: Overview of the proposed dominant-component-aware extension of TWA. For each checkpoint, leading rank-one components are extracted from selected weight matrices and added as correction directions to the TWA subspace. The final model is optimized in the expanded subspace using the ID classification objective.
We therefore do not remove dominant weight components deterministically. Instead, we introduce them into the Trainable Weight Averaging (TWA) search subspace as correction directions and learn their contributions with the ID classification objective. This allows the model to adaptively control dominant weight components while preserving discriminative information needed for ID classification. The proposed method does not modify the network architecture and incurs no additional inference-time cost because the final model is still represented by a single set of parameters.
3.2 Overview
We consider a K-class ID classification problem. Let the ID training dataset be , and let be a neural network with parameters . At test time, an input may come either from the ID distribution or from an unknown OOD distribution , whose samples do not belong to the known classes. For OOD detection, the trained model assigns a score to an input , where a higher score indicates a higher likelihood of being OOD. Given a threshold , the decision function is
where is the indicator function. Thus, when the OOD score of is at least , and otherwise; the threshold determines the ID/OOD decision boundary.
The proposed method modifies how the model parameters are obtained before applying such a detector. Following TWA, we learn the parameters in a checkpoint subspace using the ID classification objective. Let denote the classification loss, and define the empirical objective as
Let denote checkpoints saved during training, where is the vectorized parameter of checkpoint . Standard TWA optimizes model parameters in the subspace spanned by these checkpoints:
In contrast, the proposed method extracts dominant weight components from selected weight matrices of each checkpoint and constructs a dominant-component vector . We then expand the TWA search subspace using the checkpoints and the correction directions :
Subspace Extraction in Figure 1 illustrates the subspace expansion. Since , the proposed method can be interpreted as an extension of TWA that augments the search space with directions corresponding to dominant weight components. The following subsections describe how the dominant components are extracted and how the expanded-subspace coefficients are optimized.
3.3 Dominant Weight Component Extraction
Following the checkpoint-based pipeline of TWA, we process each saved checkpoint and extract dominant weight components from selected target layers. For notational simplicity, we describe the extraction for one selected weight matrix in checkpoint and denote it by , where is the output-channel or output-unit dimension and is the remaining input dimension. The same operation is applied to all selected target layers. For a fully connected layer, the weight matrix is used directly. For a convolutional layer, the weight tensor is reshaped into a two-dimensional matrix by preserving the output-channel dimension and flattening the remaining dimensions. Singular Value Decomposition (SVD) decomposes as
where and are the left and right singular-vector matrices, respectively, and is the singular-value matrix. The diagonal entries of are the singular values satisfying . The columns of and are the left and right singular vectors, respectively. We define the rank-one component corresponding to the largest singular value as the dominant weight component:
For convolutional layers, the extracted component is reshaped back to the original tensor shape. The dominant-component vector is constructed by placing the extracted components at their corresponding parameter locations and setting all remaining dimensions to zero. Thus, has the same dimensionality as and stores the dominant weight components extracted from checkpoint . In the following subspace optimization, we add to the TWA subspace as a correction direction.
A. Shinohara and H. Aizawa
3.4 Subspace Optimization
Following TWA, we construct an orthonormal basis of the expanded subspace , where . A parameter vector in the subspace is represented as using low-dimensional coordinates .
Subspace Training in Figure 1 illustrates optimization in the expanded subspace. As in TWA, the coefficient optimization is implemented as subspace training: gradients are first computed in the full parameter space and then projected onto the search subspace. The coefficients are learned from ID training data by solving
where is the regularization strength for the coefficients. In practice, rather than explicitly updating , we project the gradient with respect to the current parameter onto the subspace spanned by . With learning rate , the update is written as
The final model parameter is denoted by . Since is a basis of , there exist coefficients such that the final parameter can be equivalently expressed as
Here, denotes coordinates in the orthonormal basis, while and denote coefficients in an equivalent representation using the original checkpoints and dominant-component vectors.
3.5 Adaptive Control of Dominant Weight Components
To interpret the effect of the proposed subspace, we decompose each checkpoint as , where denotes the residual parameter after subtracting the dominant weight component in the selected layers. Equation (9) can then be rewritten as
(10)
In standard TWA, the residual component and the dominant weight component are controlled by the same coefficient. In contrast, the proposed method
Algorithm 1 Rank-1 Weight-Corrected TWA
Input: ID training set , number of checkpoints , target layer set , loss , learning rate , regularization coefficient
Output: Final parameter for OOD scoring
1: # Checkpoint Sampling
2: Collect checkpoints during training.
3: # Subspace Extraction
4: for do
5: Initialize .
6: for each target layer do
7: Extract rank-one component: .
8: Place in the corresponding entries of .
9: end for
10: end for
11: Construct .
12: Compute an orthonormal basis of .
13: # Subspace Training
14: Initialize in and set .
15: while not converged do
16: Sample a mini-batch .
17: Compute .
18: Project the gradient: .
19: Update .
20: Set .
21: end while
22: Set .
23: return
gives the dominant component an effective coefficient of , allowing its contribution to be adjusted independently from the residual component. Thus, the expanded subspace can search for solutions that retain components useful for ID classification while reducing the contribution of dominant weight components when such reduction is beneficial. The negative sign in should be interpreted as introducing a correction direction, not as deterministic component removal. Since , suppression is determined by the learned coefficients in the expanded TWA subspace.
Algorithm 1 summarizes the overall procedure. The proposed method follows the checkpoint-subspace optimization pipeline of TWA, but expands the search subspace with correction directions extracted from leading rank-one weight components.
4 Experiments
We evaluate the proposed rank-1 weight-corrected TWA on image classification-based OOD detection tasks. The experiments are designed to examine whether the proposed correction improves OOD detection over fine-tuning and standard
A. Shinohara and H. Aizawa
TWA, whether it remains effective when combined with Outlier Exposure, and how its behavior changes with the averaging range, target layers, and backbone architecture.
4.1 Experimental Setup
Datasets. We use CIFAR-100 [10] as the in-distribution (ID) dataset and evaluate OOD detection on three test datasets with different visual characteristics: SVHN [14], Textures (DTD) [2], and Places (Places365) [21]. In the Outlier Exposure (OE) setting [7], TinyImages300K [5] is used as an auxiliary outlier dataset during training. The auxiliary outlier data are separate from the OOD test datasets.
Training Details. ResNet50 [4] is used as the primary backbone. We also evaluate VGG16BN [8, 15] and WideResNet-40-2 [20] to examine whether the proposed correction is robust across architectures. Each backbone is trained for 200 epochs using SGD with a batch size of 128, an initial learning rate of 0.1, a momentum of 0.9, and a weight decay of . The learning rate is decayed by a factor of 10 at epochs 100 and 150 using a multi-step learning rate scheduler. Checkpoints are saved at the end of every epoch. Following TWA [12], we regard the saved checkpoints as candidate weights. In the comparison stage, FT, TWA, and the proposed method are optimized for an additional 50 epochs; TWA and the proposed method construct their search subspaces from the selected candidate weights.
Proposed Variants. For the proposed method, Singular Value Decomposition (SVD) is applied to the selected weight matrices of each candidate checkpoint, and the leading rank-one component is used to construct the correction direction. We investigate five choices of target layers for dominant-component extraction: all layers (all), convolutional layers only (conv), layer3, layer4, and the final classification layer (last). Unless otherwise stated, we report the variant using the final classification layer.
Evaluation. We evaluate OOD detection using Maximum Softmax Probability (MSP) [6] and Energy Score [13]. We also include RankWeight [16], a post-hoc baseline that removes dominant weight components after training. To assess feature-based detection, we additionally evaluate Mahalanobis distance [11] using features extracted from the input to the final classification layer on ResNet50, with and without OE. Performance is measured by AUROC and FPR95, where higher AUROC and lower FPR95 indicate better OOD detection. We compare the proposed method with conventional fine-tuning (FT) and Trainable Weight Averaging (TWA), and conduct ablations over the checkpoint range, target layers, and backbone architecture.
Table 1: OOD detection performance without Outlier Exposure (OE) using ResNet50. The final classification layer is used for the proposed method. RankWeight denotes the post-hoc RankWeight protocol. Throughout the tables, scores are reported as percentages, subscripts indicate differences from TWA in percentage points, and bold indicates the best result for each metric and experimental setting.
| Protocol | Method | SVHN | Textures | Places | |||
|---|---|---|---|---|---|---|---|
| AUROC (%)↑ | FPR95 (%)↓ | AUROC (%)↑ | FPR95 (%)↓ | AUROC (%)↑ | FPR95 (%)↓ | ||
| MSP | FT | 77.0 | 84.18 | 73.2 | 86.17 | 72.5 | 86.17 |
| TWA | 78.7 | 80.11 | 70.2 | 88.51 | 72.1 | 85.34 | |
| Ours | |||||||
| Energy | FT | 84.8 | 79.72 | 76.9 | 84.57 | 75.0 | 84.49 |
| TWA | 83.5 | 79.80 | 71.2 | 89.41 | 74.2 | 80.75 | |
| Ours | |||||||
| RankWeight | FT | 77.8 | 84.32 | 65.3 | 92.87 | 71.6 | 87.61 |
| TWA | 74.7 | 88.47 | 63.9 | 92.98 | 72.8 | 83.42 | |
| Ours | |||||||
4.2 Main Results
OOD Detection without Auxiliary Outlier Data. We first evaluate the proposed method in the standard setting where no auxiliary outlier data are used during training. This setting directly tests whether expanding the TWA subspace with rank-1 weight-component correction can improve OOD detection from ID training data alone.
Table 1 reports the OOD detection results without OE using ResNet50 as the backbone, organized by OOD scoring protocol. Across MSP and RankWeight, the proposed method consistently improves TWA on all OOD datasets in both AUROC and FPR95. For Energy Score, it improves AUROC on all datasets and substantially reduces FPR95 on SVHN (79.80% to 68.28%) and Textures (89.41% to 86.91%), while the FPR95 on Places is essentially unchanged from TWA (80.75% vs. 80.78%). Compared with FT, the proposed method is strongest in the MSP and RankWeight protocols, whereas FT remains competitive for Energy-based detection on Textures. These results indicate that the rank-1 correction improves the TWA solution most consistently for confidence- and rank-based OOD detection without auxiliary outlier data.
ID Classification Performance. Since the proposed correction is optimized with the ID classification objective, we also examine whether the OOD improvements come at the cost of ID accuracy. Table 2 reports CIFAR-100 ID classification accuracy in the same without-OE setting as Table 1. Standard TWA decreases accuracy compared with FT (72.55% vs. 73.94%), whereas the proposed method improves it to 75.04%, corresponding to a 2.49-point gain over TWA. These results indicate
Table 2: CIFAR-100 ID accuracy without OE.
| Method | Accuracy (%)↑ |
|---|---|
| FT | 73.94 |
| TWA | 72.55 |
| Ours |
A. Shinohara and H. Aizawa
Table 3: Effect of checkpoint averaging range on OOD detection without OE using ResNet50.
| Range | Method | MSP | Energy | ||
|---|---|---|---|---|---|
| AUROC (%)↑ | FPR95 (%)↓ | AUROC (%)↑ | FPR95 (%)↓ | ||
| (0,51) | TWA | 71.1 | 85.60 | 79.4 | 89.30 |
| Ours | |||||
| (0,101) | TWA | 74.1 | 83.50 | 83.5 | 79.80 |
| Ours | |||||
| (0,151) | TWA | 70.8 | 84.83 | 79.9 | 83.93 |
| Ours | |||||
| (101,151) | TWA | 70.1 | 87.66 | 79.4 | 86.24 |
| Ours | |||||
| (101,200) | TWA | 70.6 | 87.23 | 78.9 | 86.29 |
| Ours | |||||
that the proposed rank-1 correction improves OOD detection while preserving, and in this setting improving, ID classification performance.
4.3 Analysis of the Proposed Method
Effect of Averaging Range. Since the checkpoint averaging range determines the candidate weights that span the TWA subspace, we examine whether the proposed correction depends strongly on a particular range. Table 3 reports the results without OE using different checkpoint ranges. The proposed method improves MSP-based AUROC and FPR95 over TWA for all ranges, and also improves Energy-based AUROC across all ranges. Energy-based FPR95 is improved in most ranges, with the exception of the range (0,151). The strongest overall performance is obtained from (0,101), while the late-only ranges (101,151) and (101,200) are not consistently superior. These results suggest that the benefit of rank-1 correction is not simply due to using later checkpoints, but comes from improving the TWA subspace across a range of checkpoint selections.
Target Layers for Dominant-Component Correction. We next analyze how the choice of target layers affects the proposed correction. Table 4 reports results without OE when the leading rank-one components are extracted from different parts of ResNet50. Applying the correction to the final classification layer achieves the best performance for both MSP and Energy Score, while applying it to layer4 is also effective, especially for Energy-based detection. In contrast, applying the correction to all layers or only convolutional layers gives limited gains and can even degrade MSP-based detection. These results indicate that rank-1 weight-component correction is most effective when localized near the classifier, rather than uniformly applied across the whole feature extractor.
Table 4: Target-layer analysis for dominant-component correction without OE on CIFAR-100/SVHN using ResNet50.
| Method / Target | MSP | Energy | ||
|---|---|---|---|---|
| AUROC (%)↑ | FPR95 (%)↓ | AUROC (%)↑ | FPR95 (%)↓ | |
| FT | 77.0 | 84.18 | 84.8 | 79.72 |
| TWA | 78.7 | 80.11 | 83.5 | 79.80 |
| Ours: target layer for dominant-component correction | ||||
| all | 75.6-3.1 | 84.21+4.10 | 84.2+0.7 | 78.49-1.31 |
| conv | 75.9-2.8 | 84.53+4.42 | 80.5-3.0 | 86.14+6.34 |
| layer3 | 76.7-2.0 | 85.56+5.45 | 83.8+0.3 | 79.64-0.16 |
| layer4 | 78.6-0.1 | 81.48+1.37 | 86.9+3.4 | 71.56-8.24 |
| last | 79.0+0.2 | 79.02-1.09 | 88.4+4.9 | 68.28-11.52 |
Effect of Backbone Architectures. We further examine whether the proposed correction remains effective across different backbone architectures. Table 5 reports the results without OE for VGG16BN, ResNet50, and WideResNet-40-2. On ResNet50, the proposed method gives the most consistent improvements over TWA across datasets and scoring protocols, especially for Energy-based detection. For VGG16BN, the proposed method improves TWA in many cases, but FT remains competitive or better for MSP-based detection. For WideResNet-40-2, the gains are also mixed: the proposed method improves Energy-based results on several datasets, while TWA or FT can be stronger for MSP. These results suggest that rank-1 weight-component correction is broadly useful but its effect depends on the backbone and OOD scoring protocol, with the clearest benefit observed for ResNet50 and Energy-based detection.
4.4 Compatibility with Outlier Exposure
We first analyze whether the proposed rank-1 correction remains effective when auxiliary outlier data are used, considering both OOD detection and ID classification. Table 6 reports CIFAR-100 ID accuracy with OE. Although FT achieves the highest ID accuracy, the proposed method improves accuracy over TWA from to , reducing the ID accuracy degradation caused by TWA under OE.
Table 6: CIFAR-100 ID accuracy with OE.
| Method | Accuracy (%)↑ |
|---|---|
| FT | 73.94 |
| TWA | 69.94 |
| Ours | 72.69+2.75 |
Table 7 reports the OOD detection results with OE using ResNet50. Even under explicit outlier supervision, the proposed method consistently improves TWA across all OOD datasets for MSP, Energy Score, and RankWeight. The improvement is particularly clear for Energy-based detection on SVHN, where AUROC increases from to and FPR95 decreases from to . For Energy-based detection on Textures and Places, the gains are more moderate,
A. Shinohara and H. Aizawa
Table 5: Effect of backbone architectures on OOD detection without OE using CIFAR-100 as ID.
| Dataset | Backbone | Method | MSP | Energy | ||
|---|---|---|---|---|---|---|
| AUROC (%)↑ | FPR95 (%)↓ | AUROC (%)↑ | FPR95 (%)↓ | |||
| SVHN | VGG16BN | FT | 67.5 | 87.63 | 73.4 | 82.51 |
| TWA | 65.7 | 90.25 | 72.8 | 87.46 | ||
| Ours | ||||||
| ResNet50 | FT | 77.0 | 84.18 | 84.8 | 79.72 | |
| TWA | 78.7 | 80.11 | 83.5 | 79.80 | ||
| Ours | ||||||
| WideResNet40-2 | FT | 69.5 | 89.14 | 79.9 | 81.50 | |
| TWA | 74.6 | 86.63 | 79.7 | 86.27 | ||
| Ours | ||||||
| Textures | VGG16BN | FT | 71.9 | 86.17 | 75.9 | 83.62 |
| TWA | 69.0 | 87.45 | 73.1 | 84.89 | ||
| Ours | ||||||
| ResNet50 | FT | 73.2 | 86.17 | 76.9 | 84.57 | |
| TWA | 70.2 | 88.51 | 71.2 | 89.41 | ||
| Ours | ||||||
| WideResNet40-2 | FT | 72.8 | 86.33 | 72.5 | 89.47 | |
| TWA | 72.1 | 86.17 | 75.2 | 84.89 | ||
| Ours | ||||||
| Places | VGG16BN | FT | 72.4 | 85.76 | 73.8 | 84.38 |
| TWA | 69.2 | 88.92 | 70.1 | 86.37 | ||
| Ours | ||||||
| ResNet50 | FT | 72.5 | 86.17 | 75.0 | 84.49 | |
| TWA | 72.1 | 85.34 | 74.2 | 80.75 | ||
| Ours | ||||||
| WideResNet40-2 | FT | 73.8 | 84.15 | 75.0 | 83.70 | |
| TWA | 74.6 | 83.21 | 75.9 | 81.32 | ||
| Ours | ||||||
and FT remains competitive for some FPR95 values. Overall, these results suggest that the proposed weight-space correction is complementary to OE rather than redundant with auxiliary outlier training.
4.5 Feature-based OOD Detection
We also evaluate feature-based OOD detection. Table 8 compares FT, TWA, and the proposed method using Mahalanobis scoring on ResNet50, with features extracted from the input to the final classification layer.
The results are mixed. On SVHN and Places, the proposed method underperforms TWA in both AUROC and FPR95, with and without OE. For example, without OE on SVHN, AUROC decreases from 84.1% to 66.3%, while FPR95 increases from 55.20% to 86.29%. On Textures without OE, the proposed method improves AUROC from 86.6% to 88.2% and reduces FPR95 from
Table 7: OOD detection performance with Outlier Exposure (OE) using ResNet50. The final classification layer is used for the proposed method. RankWeight denotes the post-hoc RankWeight protocol.
| Protocol | Method | SVHN | Textures | Places | |||
|---|---|---|---|---|---|---|---|
| AUROC (%)↑ | FPR95 (%)↓ | AUROC (%)↑ | FPR95 (%)↓ | AUROC (%)↑ | FPR95 (%)↓ | ||
| MSP | FT | 79.4 | 80.22 | 74.4 | 83.99 | 75.3 | 82.10 |
| TWA | 80.5 | 77.27 | 72.1 | 86.91 | 71.1 | 85.08 | |
| Ours | |||||||
| Energy | FT | 84.2 | 75.80 | 77.4 | 81.33 | 79.9 | 75.48 |
| TWA | 85.4 | 75.00 | 74.3 | 84.68 | 75.2 | 77.06 | |
| Ours | |||||||
| RankWeight | FT | 79.9 | 84.76 | 67.4 | 91.60 | 74.7 | 84.08 |
| TWA | 73.7 | 91.22 | 63.1 | 93.62 | 73.4 | 81.55 | |
| Ours | |||||||
Table 8: Feature-based OOD detection using Mahalanobis scoring on ResNet50, with CIFAR-100 as ID. Features are extracted from the input to the final classification layer.
| OE | Method | SVHN | Textures | Places | |||
|---|---|---|---|---|---|---|---|
| AUROC↑ | FPR95↓ | AUROC↑ | FPR95↓ | AUROC↑ | FPR95↓ | ||
| w/o OE | FT | 71.2 | 77.20 | 86.6 | 43.94 | 51.5 | 95.95 |
| TWA | 84.1 | 55.20 | 86.6 | 42.23 | 52.9 | 95.50 | |
| Ours | |||||||
| w/ OE | FT | 71.2 | 79.69 | 88.6 | 38.30 | 55.0 | 94.38 |
| TWA | 84.1 | 56.64 | 85.6 | 42.71 | 58.9 | 93.66 | |
| Ours | |||||||
42.23% to 41.22%, outperforming both FT and TWA. With OE on Textures, AUROC improves over TWA by 0.8 percentage points, but FPR95 worsens by 2.40 percentage points; FT achieves the best performance on both metrics.
These results show that the gains observed with MSP and RankWeight do not consistently extend to Mahalanobis-based detection. The effectiveness of rank-1 weight correction therefore depends on the OOD scoring protocol, and improvements in confidence-based detection should not be interpreted as uniform improvements in feature-based detection.
4.6 Loss Landscape Visualization
Weight averaging is associated with flatter loss landscapes and improved generalization [9, 12]. We examine whether adding rank-1 correction directions to the TWA subspace preserves this flat-solution behavior. Figure 2 visualizes the loss landscapes of FT, TWA, and the proposed method without OE. Compared with FT, both TWA and the proposed method are located in flatter basins, and the proposed method preserves a flat landscape comparable to TWA. This suggests
A. Shinohara and H. Aizawa

Fig. 2: Loss landscape visualization without Outlier Exposure (OE). The proposed method expands the TWA search subspace while retaining the flat-solution behavior of weight averaging.
that the proposed rank-1 correction improves OOD detection while retaining the flat-solution property of weight averaging.
5 Conclusion
We proposed rank-1 weight-corrected TWA for OOD detection, augmenting the checkpoint subspace with leading rank-one correction directions learned through the ID classification objective, without changing the architecture or inference cost. On CIFAR-100 with SVHN, Textures, and Places as OOD datasets, the method improves over FT and TWA with MSP and RankWeight on ResNet50, both with and without OE. Mahalanobis results are mixed, demonstrating dependence on the scoring protocol. Analyses favor correction near the classifier and show improvements across checkpoint ranges, with effects varying by backbone. Loss landscape visualization suggests that the method retains the flat-solution behavior of weight averaging.
Discussion and Limitations. The proposed method adds SVD-based component extraction and expanded-subspace construction to the TWA optimization stage, but the final model remains a single network and incurs no additional inference-time cost. Our analyses indicate that the effectiveness of the correction depends on the target layer, backbone architecture, and OOD scoring protocol. In particular, the Mahalanobis results show that gains from weight correction do not necessarily translate to feature-space distance-based detection. The current results do not establish the cause of these degradations. Evaluation is limited to CIFAR-100 as ID with SVHN, Textures, and Places as OOD datasets; large-scale and near-OOD evaluation remain outside the scope of this study. In this work, we mainly use the leading rank-one component and select target layers manually; adaptive selection of component ranks and target layers is an important direction for applying the method to larger architectures and more diverse OOD settings.
References
-
Cha, J., Chun, S., Lee, K., Cho, H.C., Park, S., Lee, Y., Park, S.: Swad: Domain generalization by seeking flat minima. NeurIPS 34, 22405–22418 (2021) 2, 3
-
Cimpoi, M., Maji, S., Kokkinos, I., Mohamed, S., Vedaldi, A.: Describing textures in the wild. In: CVPR. pp. 3606–3613 (2014) 8
-
Du, X., Wang, Z., Cai, M., Li, Y.: Vos: Learning what you don't know by virtual outlier synthesis. ICLR (2022) 3
-
He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: CVPR. pp. 770–778 (2016) 8
-
Hendrycks, D., Basart, S., Mazeika, M., Zou, A., Kwon, J., Mostajabi, M., Steinhardt, J., Song, D.: Scaling out-of-distribution detection for real-world settings (2022), https://arxiv.org/abs/1911.11132 8
-
Hendrycks, D., Gimpel, K.: A baseline for detecting misclassified and out-of-distribution examples in neural networks. In: ICLR (2017), https://openreview.net/forum?id=Hkg4TI9xl 1, 3, 8
-
Hendrycks, D., Mazeika, M., Dietterich, T.: Deep anomaly detection with outlier exposure. In: ICLR (2019) 2, 3, 8
-
Ioffe, S., Szegedy, C.: Batch normalization: Accelerating deep network training by reducing internal covariate shift. In: ICML. pp. 448–456 (2015) 8
-
Izmailov, P., Podoprikhin, D., Garipov, T., Vetrov, D., Wilson, A.G.: Averaging weights leads to wider optima and better generalization. In: Uncertainty in Artificial Intelligence. Proceedings of Machine Learning Research, vol. R16, pp. 875–884. PMLR (2018) 2, 3, 13
-
Krizhevsky, A., Hinton, G.: Learning multiple layers of features from tiny images. Tech. rep., University of Toronto, Toronto, Ontario (2009), https://www.cs.toronto.edu/~kriz/learning-features-2009-TR.pdf 8
-
Lee, K., Lee, K., Lee, H., Shin, J.: A simple unified framework for detecting out-of-distribution samples and adversarial attacks. NeurIPS 31 (2018) 2, 3, 8
-
Li, T., Huang, Z., Tao, Q., Wu, Y., Huang, X.: Trainable weight averaging: Efficient training by optimizing historical solutions. In: ICLR (2023), https://openreview.net/forum?id=8wbnp0JY-f 2, 3, 8, 13
-
Liu, W., Wang, X., Owens, J., Li, Y.: Energy-based out-of-distribution detection. NeurIPS 33, 21464–21475 (2020) 1, 3, 8
-
Netzer, Y., Wang, T., Coates, A., Bissacco, A., Wu, B., Ng, A.Y.: Reading digits in natural images with unsupervised feature learning. In: NIPS Workshop on Deep Learning and Unsupervised Feature Learning 2011 (2011), http://ufldl.stanford.edu/housenumbers/nips2011_housenumbers.pdf 8
-
Simonyan, K., Zisserman, A.: Very deep convolutional networks for large-scale image recognition (2015), https://arxiv.org/abs/1409.1556 8
-
Song, Y., Wang, W., Sebe, N.: Rankfeat&rankweight: Rank-1 feature/weight removal for out-of-distribution detection. IEEE TPAMI 47(4), 2505–2519 (2024) 2, 3, 8
-
Sun, Y., Guo, C., Li, Y.: React: Out-of-distribution detection with rectified activations. NeurIPS 34, 144–157 (2021) 2, 3
-
Wortsman, M., Ilharco, G., Gadre, S.Y., Roelofs, R., Gontijo-Lopes, R., Morcos, A.S., Namkoong, H., Farhadi, A., Carmon, Y., Kornblith, S., et al.: Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time. In: ICML. pp. 23965–23998. PMLR (2022) 2, 3
A. Shinohara and H. Aizawa
-
Yang, J., Zhou, K., Li, Y., Liu, Z.: Generalized out-of-distribution detection: A survey. International Journal of Computer Vision 132(12), 5635–5662 (2024) 1
-
Zagoruyko, S., Komodakis, N.: Wide residual networks. In: BMVC. British Machine Vision Association (2016) 8
-
Zhou, B., Lapedriza, A., Khosla, A., Oliva, A., Torralba, A.: Places: A 10 million image database for scene recognition. IEEE TPAMI 40(6), 1452–1464 (2018). https://doi.org/10.1109/TPAMI.2017.2723009 8