Attraction-Ranking Mismatch in Out-of-Distribution Detection: Theory and Evidence from Hamiltonian Feature Dynamics
Organizations: School of Information Science and Technology, Jinan University, Guangzhou, 510632, China
Abstract
Attracting features toward learned in-distribution (ID) regions is an intuitive strategy for out-of-distribution (OOD) detection, but does such attraction improve detection? We investigate this question using class-conditioned Hamiltonian dynamics as a controlled testbed and identify an attraction-ranking mismatch: improving individual class-affinity scores need not improve the relative ordering of ID and OOD samples. Our analysis separates misalignment between the driving field and the detection score from ranking failure that persists even when they are aligned. An exact AUROC decomposition and a local boundary analysis identify relative score changes at the ID-OOD ranking boundary as the source of first-order AUROC change under regularity conditions. Experiments demonstrate that a score-aligned rule can improve performance on a held-out source validation split yet consistently degrade it after transfer, even without a single winning-class change. A separate perturbation study finds that near-boundary relative score changes track the direction of small AUROC changes in the tested settings. Finally, centroid approximation and shared scales connect the zero-step score to a static centroid family that includes the existing CTM detector. Together, these results explain why class attraction is insufficient to justify feature refinement and motivate evaluating its effect on the ranking boundary.
Figures & tables
| ID | Group | best | |||
|---|---|---|---|---|---|
| CIFAR-10 | Near | 88.59/42.36 | 88.95/40.91 | 10 | |
| Far | 91.07/31.09 | 91.56/29.95 | 10 | ||
| CIFAR-100 | Near | 79.46/63.16 | 79.72/61.88 | 3 | |
| Far | 83.41/51.10 | 84.01/49.61 | 3 | ||
| IN-200 | Near | 79.44/64.42 | 80.22/61.89 | 3 | |
| Far | 91.18/31.66 | 91.29/31.36 | 1 |
| Benchmark | Aggregate | Current winner | ||
|---|---|---|---|---|
| ImageNet-1K | ||||
| CIFAR-10 | ||||
| CIFAR-100 | ||||
| ImageNet-200 |
| Target | Static | Probe | Positive seeds | ||
|---|---|---|---|---|---|
| IN-1K/ResNet-50 | 3/3 | ||||
| IN-1K/DenseNet-121 | 3/3 | ||||
| CIFAR-10 | 0/3 | ||||
| CIFAR-100 | 1/3 | ||||
| ImageNet-200 | 0/3 |
| Stage | Interpretation | AUROC | FPR@95 | AUROC | FPR@95 |
|---|---|---|---|---|---|
| MSP | output reference | ||||
| S1 | exact full-class field | ||||
| S2 | common class scale | ||||
| S3 | radial anchor centroid | ||||
| S4 | cosine implementation | ||||
| S5 | setup-bank centroid |
Appendix figures & tables23 assets
Supplementary material from the paper’s appendix.
Appendix
| Validation benchmark | Seed | Aggregate | Aligned | C/S | |
|---|---|---|---|---|---|
| ImageNet-1K | 0 | 72.27 | 65.77 | 73.07 | 2.74/1.94 |
| 1 | 70.84 | 66.24 | 72.30 | 3.02/1.57 | |
| 2 | 72.27 | 65.95 | 73.41 | 3.02/1.88 | |
| CIFAR-10 | 0 | 89.23 | 89.93 | 87.63 | 0.57/2.17 |
| 1 | 89.18 | 90.18 | 87.93 | 0.77/2.01 | |
| 2 | 89.85 | 90.29 | 88.39 | 0.46/1.92 |
| Benchmark | Candidates | ID | OOD | Current switches | Initial switches |
|---|---|---|---|---|---|
| CIFAR-10 | all 10 | 3000 | 3000 | 0 | 0 |
| CIFAR-100 | top 20 | 3000 | 2916 | 0 | 0 |
| ImageNet-200 | top 20 | 3000 | 5289 | 0 | 0 |
| Validation target | Seed | Static | Probe | C/S | ||
| IN-1K / R50 | 0 | 92.165 | 92.205 | 0.296/0.256 | ||
| 1 | 91.269 | 91.342 | 0.336/0.263 | |||
| 2 | 91.583 | 91.638 | 0.325/0.269 | |||
| IN-1K / DN121 | 0 | 90.065 | 90.281 | 0.553/0.337 | ||
| 1 | 89.357 | 89.600 | 0.581/0.338 | |||
| 2 | 90.049 | 90.246 | 0.537/0.339 |
| Validation target | 1% | 2.5% | 5% | 10% | 25% | 100% |
|---|---|---|---|---|---|---|
| IN-1K / R50 | 11.128 | 12.013 | 13.329 | 18.480 | 43.652 | 182.907 |
| IN-1K / DN121 | 32.548 | 33.590 | 34.395 | 38.253 | 59.390 | 199.719 |
| CIFAR-10 | 0.277 | 65.996 | ||||
| CIFAR-100 | 1.831 | 16.693 | 180.182 | |||
| IN-200 | 4.976 | 40.295 | 219.853 |
| ID | Potential | ||||
|---|---|---|---|---|---|
| IN-200 Near | Gaussian | 79.44/64.42 | 79.64/63.99 | 80.22/61.89 | 79.63/62.10 |
| IN-200 Far | Gaussian | 91.18/31.66 | 91.29/31.36 | 90.68/33.10 | 88.82/34.61 |
| IN-200 Near | IMQ | 78.23/65.27 | 78.41/64.95 | 79.34/62.99 | 78.16/63.37 |
| IN-200 Far | IMQ | 89.79/34.33 | 89.90/34.06 | 90.17/33.50 | 87.09/37.39 |
| IN-1K Near | Gaussian | 66.14/77.84 | 64.51/79.27 | 61.42/79.63 | 60.94/79.63 |
| IN-1K Far | Gaussian | 77.44/65.16 | 72.71/71.29 | 74.37/69.75 | 68.51/70.71 |
| Potential | Group | AUROC | FPR@95 | AUPR-IN | AUPR-OUT |
|---|---|---|---|---|---|
| Gaussian | Near | ||||
| Gaussian | Far | ||||
| IMQ | Near | ||||
| IMQ | Far |
| ID | Potential | AUROC | FPR@95 |
|---|---|---|---|
| CIFAR-10 | Gaussian | ||
| Laplacian | |||
| Cauchy | |||
| IMQ | |||
| Matérn- | |||
| CIFAR-100 | Gaussian |
| ID | Anchor weighting | Near-OOD | Far-OOD |
|---|---|---|---|
| CIFAR-10 | Uniform | 88.59/42.36 | 91.07/31.09 |
| Effective rank/raw | 76.99/77.43 | 81.43/55.91 | |
| Effective rank/class | 88.53/42.85 | 91.04/31.12 | |
| Effective rank/global | 79.35/71.87 | 83.17/55.49 | |
| CIFAR-100 | Uniform | 79.46/63.16 | 83.41/51.10 |
| Effective rank/raw | 72.55/74.41 | 84.33/50.11 |
| Transition | AUROC | FPR@95 |
|---|---|---|
| S1 S2 | ||
| S2 S3 | ||
| S3 S4 | ||
| S4 S5 | ||
| S5 S6 | ||
| MSP S6 |
| Method | CIFAR-10 | CIFAR-100 | IN-200 | IN-1K |
|---|---|---|---|---|
| MSP | ||||
| Energy | ||||
| MaxLogit | ||||
| GEN | ||||
| ReAct | ||||
| Scale |
| Method | CIFAR-10 | CIFAR-100 | IN-200 | IN-1K |
|---|---|---|---|---|
| MSP | ||||
| Energy | ||||
| MaxLogit | ||||
| GEN | ||||
| ReAct | ||||
| Scale |
| Configuration | AUROC rank | FPR rank | Composite |
|---|---|---|---|
| CADRef | 4.000 | 3.250 | 3.625 |
| Centroid–MSP | 5.750 | 6.375 | 6.063 |
| CTM | 6.000 | 6.000 | 6.000 |
| Scale | 6.000 | 7.625 | 6.813 |
| Centroid-only | 6.750 | 7.250 | 7.000 |
| LogitGap | 6.875 | 7.750 | 7.313 |
| ID | OOD dataset | Type | MSP | Scale | CTM | Centroid–MSP |
|---|---|---|---|---|---|---|
| CIFAR-10 | CIFAR-100 | Near | ||||
| Tiny ImageNet | Near | |||||
| MNIST | Far | |||||
| SVHN | Far | |||||
| Places365 | Far | |||||
| Textures | Far |
| ID/backbone | OOD dataset | Type | MSP | Scale | CTM | Centroid–MSP |
|---|---|---|---|---|---|---|
| IN-200/R18 | SSB-hard | Near | ||||
| NINCO | Near | |||||
| iNaturalist | Far | |||||
| Textures | Far | |||||
| OpenImage-O | Far | |||||
| IN-1K/R50 | SSB-hard | Near |
| Classes | Pointwise | vs. MSP | vs. centroid | |
|---|---|---|---|---|
| 10 | 1.0 | – | ||
| 25 | 0.9 | – | ||
| 50 | 0.8 | ✓ | ||
| 100 | 0.8 | ✓ | ||
| 200 | 0.8 | ✓ | ||
| 500 | 0.8 | ✓ |
| Method | 1 image | 2 images | 3 images | 4 images |
|---|---|---|---|---|
| Fixed | 92.185/31.17 | 92.184/31.13 | 92.185/31.13 | 92.183/31.13 |
| Target | Classes | OOD corr. | Best | MSP | Fixed | Centroid-only |
|---|---|---|---|---|---|---|
| CIFAR-10/R18 | 10 | 1.0 | 88.65/42.73 | 89.72/36.40 | 89.80/36.53 | |
| CIFAR-100/R18 | 100 | 1.0 | 83.62/46.53 | 84.99/45.07 | 85.00/44.67 | |
| IN-200/R18 | 200 | 1.0 | 87.81/38.33 | 90.75/30.94 | 90.77/31.44 | |
| IN-1K/R50 | 1000 | .8 | 85.27/47.13 | 91.72/32.91 | 90.86/36.89 | |
| IN-1K/D121 | 1000 | .6 | 83.77/51.90 | 90.31/39.16 | 88.81/42.57 |
| Method | CIFAR-10 | CIFAR-100 | IN-200 | IN-1K |
|---|---|---|---|---|
| CTM | 0.994 | 1.043 | 1.037 | 1.016 |
| MSP | 1.000 | 1.000 | 1.000 | 1.000 |
| Centroid–MSP | 1.041 | 1.085 | 1.090 | 1.039 |
| SHE | 1.045 | 1.180 | 0.776 | 1.069 |
| RMDS | 1.137 | 1.146 | 1.103 | 1.509 |
| Scale | 1.141 | 1.122 | 1.158 | 1.516 |
OOD Detection
Out-of-distribution (OOD) detection identifies inputs unlike a model’s training data so systems can flag uncertainty, reject inputs, or adapt safely.
See all 239 papers