Prototype Fusion: A Training-Free Multi-Layer Approach to OOD Detection
About
Deep learning models are increasingly deployed in safety-critical applications, where reliable out-of-distribution (OOD) detection is essential to ensure robustness. Existing methods predominantly rely on the penultimate-layer activations of neural networks, assuming they encapsulate the most informative in-distribution (ID) representations. In this work, we revisit this assumption to show that intermediate layers encode equally rich and discriminative information for OOD detection. Based on this observation, we propose a simple yet effective model-agnostic approach that leverages internal representations across multiple layers. Our scheme aggregates features from successive convolutional blocks, computes class-wise mean embeddings, and applies L_2 normalization to form compact ID prototypes capturing class semantics. During inference, cosine similarity between test features and these prototypes serves as an OOD score--ID samples exhibit strong affinity to at least one prototype, whereas OOD samples remain uniformly distant. Extensive experiments on state-of-the-art OOD benchmarks across diverse architectures demonstrate that our approach delivers robust, architecture-agnostic performance and strong generalization for image classification. Notably, it improves AUROC by up to 4.41% and reduces FPR by 13.58%, highlighting multi-layer feature aggregation as a powerful yet underexplored signal for OOD detection, challenging the dominance of penultimate-layer-based methods. Our code is available at: https://github.com/sgchr273/cosine-layers.git.
Related benchmarks
| Task | Dataset | Result | Rank | |
|---|---|---|---|---|
| Out-of-Distribution Detection | CIFAR-10 ID CIFAR-100 OOD | AUC88.34 | 66 | |
| Out-of-Distribution Detection | CIFAR10 (ID) vs SVHN (OOD) | AUROC98.94 | 61 | |
| OOD Detection | ImageNet-1k ID Places OOD | AUROC80.52 | 59 | |
| Out-of-Distribution Detection | CIFAR100 (in) CIFAR10 (out) | AUROC74.47 | 57 | |
| Out-of-Distribution Detection | ImageNet-1k (ID) vs Textures (OOD) | AUROC98.48 | 43 | |
| OOD Detection | ImageNet-1k ID iNaturalist OOD | AUROC94.76 | 43 | |
| OOD Detection | ImageNet OOD Average (iNaturalist, SUN, Places, Textures) | Mean FPR95 (OOD Avg)37.43 | 33 | |
| Out-of-Distribution Detection | CIFAR100 (ID) SVHN (OOD) | AUROC96.33 | 28 | |
| Out-of-Distribution Detection | CIFAR-10 ID Average OOD | AUROC93.54 | 24 | |
| Out-of-Distribution Detection | CIFAR-100 ID Average (OOD) | AUROC88.9 | 24 |