Abstract
We measure the Out-of-domain uncertainty in the prediction of Neural Networks using a statistical notion called "Lens Depth" (LD) combined with Fermat Distance, which is able to capture precisely the "depth" of a point with respect to a distribution in feature space, without any assumption about the form of distribution. Our method has no trainable parameter. The method is applicable to any classification model as it is applied directly in feature space at test time and does not intervene in the training process. As such, it does not impact the performance of the original model. The proposed method gives excellent qualitative results on toy datasets and can give competitive or better uncertainty estimation on standard deep learning datasets compared to strong baseline methods.
Introduction
Deep learning models are notoriously overconfident. When presented with data that differs significantly from their training set—known as Out-of-Distribution (OOD) data—they often provide high-certainty predictions that are entirely incorrect. Existing solutions generally fall into two categories: intrusive methods, which require modifying the training process (e.g., Bayesian Neural Networks), and non-intrusive methods, which analyze internal features at test time.
However, many non-intrusive methods, such as Mahalanobis distance, assume that data clusters follow simple Gaussian shapes. In reality, feature-space data often resides on complex, non-linear manifolds where these assumptions fail. This paper introduces a "plug-and-play" uncertainty score that respects the actual geometry and density of the data without requiring model retraining.
Methodology
The proposed approach quantifies uncertainty by measuring how "deep" a test point lies within the geometric manifold of the training data. This is achieved by combining two mathematical concepts:
- Lens Depth (LD): A statistical measure of centrality. A point has high Lens Depth if it frequently falls within the intersection of two balls centered at random training points. Intuitively, points deep inside a cluster are likely In-Distribution (ID).
- Fermat Distance: Unlike standard Euclidean distance, Fermat distance calculates the "shortest path" between points by favoring paths through high-density regions, making it manifold-aware.
To ensure the uncertainty score vanishes as a point moves toward infinity, the authors introduced a Modified Sample Fermat Distance. Furthermore, to handle large datasets, a K-means strategy is employed, using centroids as reference points to reduce computational overhead while smoothing out irregular noise in the training data.
Experimental Results
Qualitative Performance
The method was first evaluated on toy datasets like "Two-moons" and "Gaussian" to visualize how it handles non-linear shapes. Unlike traditional metrics that assume ellipsoidal distributions, this method "follows the curve" of the data.
Quantitative Benchmarks
The method demonstrated superior OOD detection across standard image benchmarks:
- FashionMNIST vs. MNIST: Achieved an AUROC of 0.971, outperforming Euclidean (0.943) and Mahalanobis distance (0.942).
- CIFAR10 vs. SVHN: Achieved an AUROC of 0.936, surpassing complex intrusive methods like DUQ (0.927) and Deep Ensembles (0.926).
Discussion and Key Insights
A primary takeaway is that the geometry of the feature space is often more informative than its simple statistical properties. By utilizing Fermat distance, the model respects the manifold structure of the data. Because the method is applied to the penultimate layer of a pre-trained network, it is entirely non-intrusive and does not degrade classification accuracy.
Limitations
While effective, the method faces challenges in computational complexity compared to simple Softmax scores. Additionally, its performance is inherently tied to the quality of the pre-trained feature extractor; if the backbone fails to organize data into meaningful clusters, the uncertainty quantification will be less reliable. Future work will focus on more efficient algorithms for computing Lens Depth at scale.
Summary updated