arXiv:2608.23499cs.CVAug 2026

Manuscript Offprint

arXiv:2608.23499

SVD-Based Typicality Maps for Out-of-Distribution Detection in Vision Transformers

Aldo Sean Sartor, Leandro de Souza Rosa, Andriy Enttsel, Mauro Mangia, Riccardo Rovatti

Aldo Sean Sartor*, Leandro de Souza Rosa*, Andriy Enttsel*, Mauro Mangia*†, Riccardo Rovatti*†

*DEI, †ARCES, University of Bologna, Italy; contact author: aldosean.sartor@unibo.it

Abstract—We present a method for analyzing the internal representations of Vision Transformers (ViTs) exploiting the geometry of their learned parameters. Each affine layer's weight matrix is factored via Singular Value Decomposition (SVD), and activations are projected onto the leading right singular vectors to obtain compact, layer-intrinsic representations. A class-conditional density model is then fitted at each layer, producing per-class typicality scores that are stacked across depth into typicality maps: two-dimensional summaries of how class-specific evidence evolves through the network. From these maps, we derive two post-hoc scores for Out-Of-Distribution (OOD) detection: a Prototype Alignment Score (PAS), measuring agreement with class reference prototype patterns, and a Multi-Layer Soft Voting (MLSV) score, capturing cross-layer consensus without stored prototypes. On ViT-B/16 fine-tuned on CIFAR-100, the proposed scores achieve competitive detection performance without retraining or OOD exposure.

Index Terms—Singular Value Decomposition, Vision Transformer, Out-of-Distribution Detection, Feature Geometry.

I. INTRODUCTION

Deep neural networks construct high-dimensional internal representations through cascades of learned linear transformations and nonlinearities. While these representations are central to a model's performance, their geometry and evolution across depth remain difficult to characterize, especially for modern deep architectures. In this work, we focus on Vision Transformer (ViT) [1] classifiers, where information is progressively transformed by alternating self-attention and multilayer perceptron (MLP) blocks acting on token embeddings. A principled, layer-wise view of how class-relevant structure emerges is important both for interpretability and for reliability tasks such as detecting inputs that fall outside the training distribution [2].

An increasing number of post-hoc methods address these questions by analyzing intermediate activations of a frozen, pretrained network, rather than relying solely on the output-layer's scores [3], [4]. Methods based on distances in activation space, such as Deep Mahalanobis Distance (DMD) [5] and Deep k-Nearest Neighbors (k-NN) [6], capture distributional information beyond the logits. However, they typically operate on a single layer or require task-specific supervision, such as Out-Of-Distribution (OOD) validation data for the logistic-regression step in DMD.

More recently, a multi-layer confidence framework called MACS (Multi-layer Analysis for Confidence Scoring) [7] has shown that aggregating layer-wise evidence into structured maps can unify confidence estimation, OOD detection, and adversarial-attack detection. Concretely, MACS probes the internal activations of a trained network via SVD-based projections [8] and aggregates layer-wise information into structured maps, which are then compared against class-specific prototypes. While MACS demonstrates the effectiveness of this representation for confidence and reliability assessment, it relies on unsupervised clustering in the projected activation space, followed by an empirical feature-label association step to obtain layer-wise class estimates.

In this work, we propose a simpler and probabilistic alternative. We preserve the same geometric backbone: we interpret each affine layer as a linear operator, factorize its augmented weight matrix via Singular Value Decomposition (SVD) [9], and project activations onto the directions along which the layer maximally amplifies its input, to obtain compact, layer-intrinsic representations. However, instead of relying on clustering and empirical feature-label association, we adopt class-conditional density modeling in the SVD-projected space. This yields per-layer, per-class typicality scores, which, when stacked across depth, form typicality maps that play the same structural role as MACS classification maps while reducing the number of processing stages and hyperparameters and providing scores with a direct probabilistic interpretation. These maps reveal how class-specific evidence emerges through the network. From these maps, we then derive two scalar scores: the Prototype Alignment Score (PAS), measuring agreement with class-specific reference maps analogous to MACS's prototype-matching; and the Multi-Layer Soft Voting (MLSV) score, which captures cross-layer consensus without requiring any stored prototypes. Both scores are fully post-hoc and do not require access to OOD data.

We validate the framework on ViT-B/16 fine-tuned on CIFAR-100. PAS and MLSV achieve competitive OOD detection against established baselines while providing a depth-resolved representation of the network's internal dynamics.

Our contributions can be summarized as follows:

• Probabilistic reformulation: We replace MACS’s clustering and feature-label association with class-conditional density modeling in the SVD-projected space, yielding per-layer, per-class typicality scores with a direct probabilistic interpretation.

• Simpler maps: We introduce typicality maps, which play the same role as MACS classification maps but with a simpler pipeline and fewer hyperparameters.

The work of Andriy Enttsel was done before joining Mitsubishi Electric R&D Centre Europe.

Figure

Fig. 1: Overview of the proposed pipeline. Left: schematic of a ViT encoder block (repeated ×12) with the classification head. Red dots mark the three hook types used to intercept CLS-token activations. Right: the activations processing pipeline, divided into an OFFLINE stage (teal, performed once per model) and an ONLINE stage (orange, applied to each test sample).

• Novel scores: We derive two post-hoc scores: PAS, which simplifies MACS’s prototype-matching score, and MLSV, a new prototype-free score capturing cross-layer consensus.

The remainder of this paper is organized as follows. Section II presents the mathematical models. Section III defines the experimental setup and describes the datasets. Section IV reports and discusses the empirical findings. Section V concludes the paper.