Abstract
Numerous recent works utilize bi-Lipschitz regularization of neural network layers to preserve relative distances between data instances in the feature spaces of each layer. This distance sensitivity with respect to the data aids in tasks such as uncertainty calibration and out-of-distribution (OOD) detection. In previous works, features extracted with a distance sensitive model are used to construct feature covariance matrices which are used in deterministic uncertainty estimation or OOD detection. However, in cases where there is a distribution over tasks, these methods result in covariances which are sub-optimal, as they may not leverage all of the meta information which can be shared among tasks. With the use of an attentive set encoder, we propose to meta learn either diagonal or diagonal plus low-rank factors to efficiently construct task specific covariance matrices. Additionally, we propose an inference procedure which utilizes scaled energy to achieve a final predictive distribution which is well calibrated under a distributional dataset shift.
Introduction
Deep Neural Networks (DNNs) are notoriously overconfident, often assigning high probabilities to incorrect or out-of-distribution (OOD) inputs. This lack of "self-awareness" regarding uncertainty is a critical safety concern in high-stakes applications like medical diagnosis or autonomous driving. In the context of meta-learning—where models must learn to generalize from a few examples—this problem is exacerbated. Traditional Prototypical Networks represent classes as single mean points (prototypes), often ignoring the underlying data distribution's shape or covariance. Estimating complex covariance matrices in few-shot settings is inherently difficult due to the scarcity of data points. Furthermore, the standard softmax function is shift-invariant, focusing only on relative distances and failing to account for absolute distances from the training data manifold.
Methodology: Proto Mahalanobis
To address these challenges, we introduce Proto Mahalanobis, a framework that enhances few-shot learning with robust uncertainty estimation through three key components:
1. Meta-Learned Covariance Factors
Rather than attempting to calculate covariance directly from a few samples, we employ an attentive set encoder (specifically, a Set Transformer) to predict task-specific covariance matrices. To maintain computational efficiency, we parameterize these matrices as a combination of a diagonal matrix and a low-rank factor: $\Sigma_c = \Lambda_c + \Phi_c \Phi_c^\top$. This approach allows the model to leverage meta-knowledge across various tasks to infer how features typically vary, even when only one or five examples are available.
2. Bi-Lipschitz Regularization
We apply spectral normalization to the network's layers to ensure bi-Lipschitz continuity. This makes the model "distance-sensitive," preserving the relative distances between inputs in the feature space. This prevents "feature collapse," where OOD data might otherwise be mapped into regions occupied by in-distribution data, thereby improving OOD detection.
3. Scaled Energy Inference
To mitigate the overconfidence inherent in the softmax function, we incorporate an energy-based term into the inference procedure. We model the output as a logit-normal distribution where the variance is scaled by the "energy"—a scalar measure of how unusual an input is relative to the training data. As energy increases (indicating OOD data), the variance spikes, causing the final predictive distribution to tend toward a uniform distribution, reflecting high uncertainty.
Experimental Results
The proposed method was evaluated on standard few-shot benchmarks (Omniglot, MiniImageNet) and their corrupted counterparts (Omniglot-C, MiniImageNet-C) to test robustness under distributional shifts.
Toy Datasets and Uncertainty Surfaces
Visualizations on toy datasets like "Meta-Circles" and "Meta-Gaussians" demonstrate the model's ability to learn meaningful uncertainty boundaries. Unlike standard Prototypical Networks, Proto Mahalanobis produces uncertainty surfaces that closely follow the data distribution.
Calibration and OOD Detection
On the Omniglot 5-way 5-shot task, Proto Mahalanobis significantly improved calibration. The Expected Calibration Error (ECE)—a measure of how much a model's confidence matches its actual accuracy—dropped from approximately 65-69% in baseline models to 33%. In OOD detection scenarios, the model maintained higher uncertainty for unseen classes compared to Prototypical Networks or MAML. Furthermore, Proto Mahalanobis exhibited superior robustness to noise; as corruption intensity increased in MiniImageNet-C, its calibration degraded much more slowly than state-of-the-art baselines like SNGP or DDU.
Discussion and Conclusion
While Proto Mahalanobis offers significant improvements in uncertainty estimation, some limitations remain. In extreme 1-shot scenarios, the lack of multiple points per class prevents effective mean-centering, which can reduce the diversity of predicted covariance matrices. Additionally, the energy-scaling mechanism requires post-training tuning of a temperature parameter on a validation set. Despite the increased architectural complexity of the set encoder, the use of the Sherman-Morrison formula and matrix determinant lemma ensures that the computational overhead remains manageable, avoiding $O(d^3)$ matrix inversions during training. Future work will focus on simplifying the set encoder architecture while maintaining its expressive power for covariance prediction.
Summary updated