Uncertainty That Survives Attack, Without Adversarially Retraining the Backbone

A model's uncertainty is useful only if it rises when the model is wrong. Under attack it often does not. An adversary can push an input so that the prediction becomes wrong and the model becomes more confident at the same time. Adversarial Attacks Against Uncertainty Quantification did this to deep ensembles and Monte Carlo dropout, collapsing ensemble variance to about $10^{-6}$. The authors call for "adversarial training for uncertainty". That is costly: adversarial training already multiplies training compute by roughly 10–40× because each weight update needs an inner loop of attack steps. Asking it to also protect the uncertainty signal makes that inner loop harder.

This note proposes a cheaper route built on geometry. We keep a large pretrained image model frozen. On top of its features we train a small scoring head. The head's uncertainty is defined as the angular distance from the input's feature to a local approximation of the clean data surface for the predicted class. A rank loss then forces that distance to order test inputs the same way their errors do, including on attacked inputs. The bet is this: if uncertainty is tied to how far a feature sits off the clean data surface, an attacker cannot both flip the label and look confident within a small perturbation budget. To look confident it must land back on the surface of the wrong class, and that is a much larger move than flipping the label.

Core Claim

The claim is that most of the robustness of the uncertainty–error relationship can be recovered with three ingredients. The first is a frozen backbone. The second is a small head whose uncertainty is a distance to class-wise data surfaces on the unit hypersphere of normalized features. The third is a training signal that rewards rank agreement between uncertainty and error, in the sense of Spearman correlation, on attacked examples. Our target is to match, at a small fraction of the compute, what full adversarial training for uncertainty would achieve. We measure success by misclassification-detection quality and Spearman correlation under an adaptive attack that targets our own score. We do not measure it by clean calibration.

The second, falsifiable sub-claim is about cost. Most of the benefit should survive if the training-time attacks are run in feature space, which needs no backpropagation through the backbone, rather than in pixel space. If that holds, training cost reduces to a few passes over cached features.

Where this sits relative to prior work

Several papers motivate the gap. Ledda et al. supply the threat model and the open call above. Success of Uncertainty-Aware Deep Models Depends on Data Manifold Geometry compares six uncertainty methods on toy data and MNIST. It finds that single-pass distance-aware models (DUQ, SNGP) "hug" the data in low ambient dimension. Ensembles instead "cling" to boundaries that fill empty space when the data is a thin surface in high-dimensional pixel space.

That finding constrains our design in a real way. It suggests that a plain distance-based score may fail where ensembles succeed. We therefore do not measure distance in pixel space. We measure it in the normalized feature space of a pretrained backbone, where class structure is far more compact. We also test directly whether the "cling" advantage of ensembles survives an adaptive attack, which Penrod et al. do not evaluate. That question bears on the unresolved tension between their paper and Ledda's.

USAD shows that adversarial examples are displaced off the clean feature manifold and detects them statistically. It works on batches of at least 10 queries and adds multi-pass covariance computations at test time. We use the same displacement intuition but make it a per-sample, single-pass score that is trained to be ranked correctly.

Other work supplies methods we reuse. Robustness Tokens shows that a frozen DINOv2 can be made robust by training ten prepended tokens for about 200 steps. Its pull-adversarial-features-back-to-clean objective is the cheap-training template we follow. It produces no uncertainty estimate, and it depends on the tokens staying secret; our head has no secrecy assumption.

Measuring and Modeling Uncertainty Degree for Monocular Depth Estimation supplies two things. One is the argument that Spearman correlation between uncertainty and error separates uncertainty quality from base accuracy. The other is a pairwise ranking loss that enforces it in a single deterministic pass. We carry both from per-pixel depth regression to per-image classification under attack.

Hyperspherical Variational Auto-Encoders replaces the Gaussian latent prior with von Mises–Fisher distributions, which are Gaussian-like distributions on the sphere. It motivates measuring angular rather than Euclidean distance once features are normalized. The Geometry of Phase Transitions in Diffusion Models ties model behavior to the "reach" of a thin tube around the data surface, roughly how far one can move off the surface before nearest-point projection becomes ambiguous. It suggests that the radius at which our distance score saturates should be measured rather than assumed.

Two papers are closest in spirit and contrast with ours. On-manifold Adversarial Data Augmentation (OMADA) attacks the latent code of a trained BigBi-GAN and labels the decoded images with soft labels. This improves calibration error by up to 9.8× on CIFAR-100. It requires generative pretraining and full classifier retraining, and it is never tested against an attacker who targets the uncertainty. Enhancing the Adversarial Robustness via Manifold Projection projects inputs through a trained autoencoder inside adversarial training. It reports AutoAttack gains of up to 33.75%, but it adds autoencoder cost in the loop, has no uncertainty component, and is weakened when the attacker differentiates through the autoencoder. Both learn the manifold with an extra generative model and retrain the classifier. We use the backbone's own features, retrain nothing in the backbone, and optimize uncertainty ranking rather than label accuracy.

Research Program

Let $z(x)$ be the backbone feature of image $x$, normalized to the unit sphere. For each class $c$ we store a set of anchor features from clean training images. Around each anchor $a$ we fit a local tangent patch: the top-$k$ principal directions of its nearest same-class neighbors. A learned head $g$, a two-layer map applied to $z(x)$, outputs a refined feature $\tilde z$. The uncertainty is the angular distance from $\tilde z$ to the nearest patch of the predicted class $\hat c$:

$$u(x) = \min_{a \in A_{\hat c}} \arccos\big(\langle \tilde z, \Pi_a \tilde z / \|\Pi_a \tilde z\| \rangle\big),$$

Here $A_{\hat c}$ is the anchor set of the predicted class, and $\Pi_a$ projects onto the affine patch at anchor $a$. The patches give an inexpensive local model of a curved class surface. We are not using one global tangent plane, whose distortions far from the base point are well documented.

The head is trained on mixed clean and attacked examples with the ranking loss of the depth paper:

$$L_{\text{rank}} = \sum_{(i,j):\, e_i > e_j} \max\big(0,\; m - (u_i - u_j)\big).$$

Here $e_i$ is the cross-entropy of the true class on example $i$, and $m$ is a margin. A standard classification loss keeps the predicted label accurate.

Attacked training examples come from a joint attack in the style of Ledda's overconfidence attack. It maximizes $e$ while minimizing $u$, and it adapts to our score. We run this attack in two variants. The pixel-space variant takes few steps and backpropagates through the frozen backbone without updating its weights. The feature-space variant perturbs cached features inside a ball whose radius is calibrated from pixel-space attacks on a small subset; it costs only head-sized computation. Comparing the two variants is the test of the cost sub-claim.

We will also measure, as an analysis, the distance at which $u$ stops growing under increasing perturbation. That empirical "reach" tells us where the guarantee-like intuition breaks.

Baselines

The naive reference point is a frozen backbone with a linear classifier and softmax entropy as the uncertainty, with no defense. It shows how badly the joint attack breaks the uncertainty–error relationship in our setting. We expect Spearman correlation near or below zero, consistent with Ledda's variance collapse.

The strongest cheap-robustness competitor is a robust model from the RobustBench model zoo (RobustBench), using its own entropy as uncertainty, temperature-scaled on clean validation data. RobustBench documents that such models are underconfident. Underconfidence does not imply poor ranking, though, and a model that resists label flips may already resist the joint attack. On ImageNet-1K the cheap-robustness reference is Robustness Tokens on DINOv2-G. That paper reports robust accuracy recovering from 0.3% to 63.1% under white-box attack, with clean accuracy of 85.2% versus 85.6%. We pair it with entropy as the uncertainty and give it the same frozen backbone and the same 200-step budget as our head.

The strongest existing method for robust uncertainty is the expensive one: full adversarial training for uncertainty. This is PGD adversarial training whose inner loop runs the joint label-flip-plus-confidence attack. It is the upper bound we aim to approach, not beat. We will also run a five-member ensemble attacked with Ledda's stabilizing attack. No reported Spearman correlation or misclassification-detection result under uncertainty-targeted attack on CIFAR or ImageNet classification was found on Lacuna. The only reported Spearman value in the file is 0.3284 on NYU Depth V2 for the depth ranking model, a different task. We therefore establish these numbers ourselves under one protocol.

Ablations isolate the geometry. The first trains the same head with the same rank loss but defines uncertainty as entropy of the head's output; this removes the manifold distance. The second uses the manifold distance with no rank loss and no attacked training; this is in the spirit of feature-distance detectors. The third replaces the local patches with a single global tangent plane per class. The fourth uses Euclidean rather than angular distance.

All methods share the same backbone, data, attack budget (an $\ell_\infty$ radius of 8/255 on CIFAR and 4/255 on ImageNet), and hyperparameter search of equal size. Cost is reported as backbone forward-plus-backward passes and GPU-hours.

Beating a baseline has a specific meaning here. Our method must achieve higher misclassification-detection AUROC and higher Spearman correlation under the adaptive joint attack against our own score, with overlapping clean accuracy. The full-training upper bound is the exception: there, success means closing at least most of the gap from the naive model at under a tenth of its compute.

Why not just…?

Why not just use temperature scaling on an adversarially trained model? Temperature scaling rescales all logits monotonically. It therefore cannot change the order of inputs by confidence, and order is exactly what Spearman correlation and misclassification detection measure. It also cannot stop an attacker who saturates the softmax. That argument covers temperature only, and the underlying robust model is a genuine threat. If RobustBench models already rank their errors well under the joint attack, our method adds little on CIFAR. The first experiment settles this directly, and we would report it as a finding either way.

Why not just use deep ensembles or Monte Carlo dropout? Ledda et al. show that the stabilizing attack drives all members to the same wrong answer, collapsing variance to about $10^{-6}$. Ensembles also multiply training and inference cost. Penrod et al. argue that ensembles cover empty off-manifold space better than single-pass distance models in high dimension, so we do not dismiss them. We run a five-member ensemble under the identical adaptive attack. If its ranking survives better than our head, the "cling beats hug" hypothesis wins in feature space too, and the geometric design is wrong.

Why not just train Robustness Tokens and read uncertainty from the entropy? This is the cheapest strong option. It is dangerous because a model that rarely errs under attack may be good enough. Robustness Tokens, however, optimizes feature alignment and accuracy, not the ordering of errors. Its remaining 37% of errors on DINOv2-G may still be confident. The comparison against the tokens-plus-entropy baseline, and the ablation that adds our rank loss to an entropy score, show whether the distance score matters or the rank loss alone does the work.

Why not just learn the manifold with an autoencoder or GAN, as OMADA and manifold projection do? Both add a separately trained generative model and full classifier retraining. Manifold projection is weakened when attackers differentiate through the autoencoder. We test an attacker with full white-box access to the head and the anchors. Our approach is only worth preferring if it holds up under that attack at lower cost.

Proposed Experiments

The first decisive check is a measurement before any training. On CIFAR-10 and CIFAR-100 with RobustBench models, and on ImageNet-1K with frozen DINOv2, we run the joint attack against softmax entropy. We report Spearman correlation between uncertainty and true-class loss, misclassification-detection AUROC, and the fraction of wrong predictions made with low uncertainty. This tells us how large the problem is for robust and non-robust backbones, and whether robust backbones already solve it.

The main experiment trains the head on each backbone and compares it with every baseline under an adaptive attack. The attack minimizes $u$ directly, uses the anchors and head, and adds AutoAttack components for the label. Robust accuracy will be checked with AutoAttack so that gradient masking cannot inflate results. RobustBench showed that many published defenses overstated robustness by more than 10% before AutoAttack.

The cost experiment compares pixel-space and feature-space training attacks. It reports AUROC and Spearman correlation against GPU-hours alongside the full adversarial-training-for-uncertainty upper bound.

The geometry experiment runs the ablations and measures the reach of $u$ as perturbation size grows. If the angular, patch-based score does not beat entropy trained with the same rank loss, the geometric claim fails, and the result reduces to "rank losses help under attack." If feature-space attacks do not transfer to pixel-space attacks, the cost claim fails. As a secondary transfer test, we will run the same pipeline on the SPDNet features for HDM05 from A Riemannian Network for SPD Matrix Learning. In that setting the base representation is itself curved, which tests whether the method depends on the hypersphere specifically.