Function Space Diversity for Uncertainty Prediction via Repulsive Last-Layer Ensembles

Sophie Steger, Christian Knoll, Bernhard Klein, Holger Fröning, Franz Pernkopf

TL;DR

Deep ensembles provide excellent uncertainty estimates but are computationally expensive to train and store. This paper introduces Repulsive Last-Layer Ensembles (RLL-E), a parameter-efficient method that achieves deep-ensemble-level uncertainty quality by adding multiple diverse prediction heads to a single shared backbone. By enforcing function-space diversity on unlabeled out-of-distribution data or augmented samples, it seamlessly brings robust uncertainty estimation to pretrained models at a fraction of the cost.

What Problem Does This Paper Address?

Deep learning models are notoriously overconfident on data they haven't seen before, which poses severe risks in safety-critical applications like autonomous driving or medical diagnostics. To fix this, we need models that can accurately signal their own limitations—specifically by measuring epistemic uncertainty (the uncertainty due to a lack of training data).

While Deep Ensembles (DE) mitigate this by training multiple models independently, replicating massive modern backbones (like ResNets or ViTs) is computationally prohibitive. Particle-Optimization Variational Inference (POVI) tries to enforce diversity among a set of "particles" (models) using a repulsion term. However, doing this in parameter space fails because different weights can produce identical functions. Doing it in function space is theoretically ideal but practically difficult: forcing diversity on the training data itself leads to underfitting, and modern pretrained models lose initialization diversity when fine-tuned.

Methods

The authors propose Function-Space Repulsive Last-Layer Ensembles (fs-RLL-E). Instead of duplicating the entire network, they use a single shared backbone and append multiple linear classification heads (each representing a particle).

Overview of the repulsive last-layer ensemble (fs-RLL-E) architecture.

To inject diversity without destroying in-domain accuracy, they apply a function-space repulsion loss exclusively on a carefully chosen set of repulsion samples (unlabeled out-of-distribution data or label-destroying data augmentations like shuffled image patches). This forces the heads to agree on the training data but disagree wildly on unfamiliar inputs, accurately capturing epistemic uncertainty.

Datasets

The method was evaluated across a variety of setups:

  • In-distribution / Evaluation: DirtyMNIST (designed for separating aleatoric vs. epistemic uncertainty), CIFAR-10, CIFAR-100, CIFAR-10-C, CIFAR-100-C (for covariate shift), Food101, and Stanford Cars (for transfer learning).
  • Out-of-Distribution (OOD) Benchmarks: FashionMNIST, EMNIST, Omniglot, Places365, SVHN, ImageNet-O, Country211, and TinyImageNet.
  • Repulsion Datasets: kMNIST, Textures, ImageNet-21k, and Patches-8 (augmented patches).
Examples of repulsion samples used to enforce function space diversity.

Key Insights and Ideas

  • Don't Repel on Training Data: Forcing prediction diversity on the training set artificially inflates uncertainty where the model should be confident, degrading accuracy.
  • The Power of Structured OOD Repulsion: Enforcing diversity on structured, unlabeled OOD data (like the Textures dataset) teaches the heads to ignore spurious features and focus on robust representations.
  • Backbone Sharing Works: You don't need full ensemble diversity throughout the entire feature extractor; a strong, distance-aware pretrained backbone combined with a repulsive last layer is enough to recover missing epistemic uncertainty.

Key Results

  • Massive Efficiency Gains: For a ResNet18 ensemble with 10 members, a full Deep Ensemble requires 112.28M parameters and a 9.84x training overhead. fs-RLL-E requires only 11.69M parameters (a tiny fraction more than a single model) and has a negligible 1.01x inference latency overhead because the backbone is only evaluated once.
  • Superior OOD Detection: On Food101 using a pretrained ResNet18, fs-RLL-E with Textures as repulsion data boosted OOD detection AUROC from 87.38% (standard last-layer ensemble) to 95.30%.
  • Robust Calibration: Under severe covariate shift (CIFAR-10-C), fs-RLL-E achieved Expected Calibration Error (ECE) and Negative Log-Likelihood (NLL) scores highly competitive with full deep ensembles.

Limitations and Future Work

  • Repulsion Sample Dependency: The method relies heavily on choosing good repulsion samples. If the deployment OOD data looks completely different from the repulsion data chosen during training, the uncertainty estimates might degrade.
  • Task Modality: The empirical evaluation is currently limited to vision classification tasks. Future work needs to validate this approach on regression and other modalities (like NLP).
  • Uncertainty Metrics: The paper relies on mutual-information-based epistemic uncertainty, which has faced recent theoretical criticism regarding complete predictive uncertainty decomposition.

Summary updated

BibTeX
@article{steger2025function,
  author = {Sophie Steger and Christian Knoll and Bernhard Klein and Holger Fröning and Franz Pernkopf},
  title = {{Function Space Diversity for Uncertainty Prediction via Repulsive Last-Layer Ensembles}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=G8fAj5gzEp},
}
Figure