Image classifiers have three well-known weaknesses. Their input gradients look like static instead of object shapes. Their feature-attribution maps flip under imperceptible noise. They give confident answers on inputs unlike anything they were trained on. The usual repairs each cost something. Adversarial training (training on worst-case perturbed inputs) cleans up gradients and stabilizes explanations but lowers clean accuracy. Outlier exposure (training against a large external dataset of "other" images) fixes overconfidence but depends on data that is often unavailable. This note argues that all three weaknesses share one geometric cause: the model is too sensitive in directions that leave the data manifold, the low-dimensional surface where natural images live. If that is true, one training signal built only from the in-distribution data can address all three without paying the accuracy cost.
The method is simple. Estimate, for each training image, which pixel directions point off the manifold. Push the image along those directions. Ask two different things of the model depending on how far the push went. For small pushes, the predicted class distribution should not change. For larger pushes, the model's overall confidence should drop, measured by its "energy", a score that rises on unfamiliar inputs. Softmax probabilities are unchanged when a constant is added to every logit, so the model can lower its confidence without changing which class it prefers. The two demands therefore do not conflict. The off-manifold pushes serve as free synthetic outliers, and the invariance requirement is exactly the kind of robustness that theory links to perceptually aligned gradients.
Core Claim
The claim draws on two results and one contradiction between them.
The first result is the off-manifold robustness account of Which Models have Perceptually-Aligned Gradients? An Explanation via Off-Manifold Robustness. That paper shows that if a classifier is robust to perturbations orthogonal to the data manifold, its input gradients must lie along the manifold and therefore look like object structure. It also separates a "Bayes-aligned" regime, where the model is off-manifold robust with accuracy preserved, from an "excessive" regime, where the model also ignores on-manifold signal and both accuracy and gradient quality collapse. This paper motivates the proposal.
The contradiction comes from TART: Boosting Clean Accuracy Through Tangent Direction Guided Adversarial Training. TART estimates the manifold's tangent directions with an autoencoder. It then trains on clean data whenever an adversarial perturbation points mostly off-manifold, and on the adversarial example otherwise. It argues that off-manifold perturbations are what warp the decision boundary. Its gains are real: clean accuracy on CIFAR-10 with WideResNet-32-10 rises from 81.76% to 83.73% with AutoAttack robustness of 36.58%. Read literally, though, TART removes exactly the training signal that the first paper says produces aligned gradients. No one has measured gradient alignment or explanation stability in TART-style models.
The hypothesis here is the reverse of TART's reading. The accuracy cost of adversarial training comes from forcing invariance along tangent directions, which are the directions that carry class evidence. Off-manifold invariance, by contrast, is nearly free. Our method trains the off-manifold component explicitly, so TART's experimental knob, which direction the perturbation points, becomes the deciding test between the two accounts.
The second result is from outlier detection. Geometrically Constrained Outlier Synthesis (GCOS) finds low-variance principal directions of penultimate-layer features. It samples synthetic outliers in a shell just beyond the data and raises their energy, with no external data. It reports an average AUROC of 93.47% on four near-OOD benchmarks. VOS: Learning What You Don't Know by Virtual Outlier Synthesis does something similar with class-conditional Gaussians in feature space. Both work only in feature space and never touch input gradients or robustness.
Our proposal moves the shell idea into input space and attaches it to the same off-manifold directions used for robustness. The new claim is that one estimate of the off-manifold directions, combined with the split between class distribution and energy, yields three things together: aligned gradients, stable attributions and outlier-free OOD detection, all without the clean-accuracy drop of isotropic adversarial training.
The Objective
Notation:
- $f(x)\in\mathbb{R}^K$ are the logits of the classifier on image $x$.
- $p(x)=\mathrm{softmax}(f(x))$ is the predicted class distribution.
- $E(x)=-\log\sum_k e^{f_k(x)}$ is the energy, which is higher for unfamiliar inputs.
- $P_N(x)$ projects a pixel-space vector onto the estimated off-manifold (normal) directions at $x$.
We draw two kinds of normal-direction pushes:
- a small worst-case push $\delta_s = P_N(x)\,\delta$, with $\delta$ found by one or two gradient steps and $\|\delta_s\|\le\epsilon$;
- a larger push $\delta_\ell = P_N(x)\,u$, with $u$ random and rescaled so that $\|\delta_\ell\|\in[r_{lo}, r_{hi}]$.
The training loss is
$$ \mathcal{L} = \mathrm{CE}(f(x),y) + \lambda_1\,\mathrm{KL}\big(p(x)\,\|\,p(x+\delta_s)\big) + \lambda_1\,\mathrm{KL}\big(p(x)\,\|\,p(x+\delta_\ell)\big) + \lambda_2\,\big[m - E(x+\delta_\ell) + E(x)\big]_+ , $$
where $m$ is an energy margin and $[\cdot]_+$ is the hinge.
The first KL term is the off-manifold invariance that should produce aligned gradients and stable attributions. The hinge term is the outlier-exposure signal. The second KL term keeps the class ranking fixed even for distant off-manifold points, so the energy can rise without the predicted class flipping.
The shell radii $[r_{lo}, r_{hi}]$ are set from the distribution of autoencoder reconstruction distances on held-out training images. This mirrors GCOS's percentile shell, but in pixel space. The off-manifold projection $P_N$ reuses TART's machinery: an autoencoder trained only on the in-distribution data, with local tangent bases obtained from its decoder Jacobian by PCA. TART reports that this machinery adds roughly 1.24x training time over standard adversarial training. No external images and no diffusion model are needed.
Research Program
Diagnostic study. The first part tests the tension directly before any new method is trusted. Starting from the same PGD adversarial training recipe, we train variants that keep only:
- the tangent component of each perturbation,
- only the normal component,
- the full isotropic perturbation,
- TART's top-50% rule.
For each model we measure:
- clean accuracy;
- AutoAttack accuracy;
- gradient perceptual alignment, as the LPIPS distance between input gradients and diffusion score vectors, following the measurement protocol of the off-manifold robustness paper (a diffusion model is used only for evaluation, never for training);
- attribution fragility, using Max-Sensitivity and Infidelity from How Sensitive are Sensitivity-Based Explanations? and the representation- and output-relative stability measures from Rethinking Stability for Attribution-based Explanations;
- attribution sparsity via the Gini index, as in Concise Explanations of Neural Networks using Adversarial Training.
The predictions differ cleanly between the two accounts. Our account predicts that normal-only training keeps accuracy near the standard-training level and gives well-aligned gradients. It also predicts that tangent-only training is the variant that loses accuracy. TART's reading predicts the opposite ordering.
The full objective. The second part adds the energy shell and compares the result against robustness, explanation and OOD baselines.
Probing the direction estimate. The third part asks how good the off-manifold estimate must be. We replace the autoencoder projection with three alternatives:
- isotropic Gaussian directions, which in high dimensions are almost entirely off-manifold;
- PCA on raw pixels;
- an oracle normal space derived from a diffusion denoiser.
This shows whether the method's value lies in the direction estimate or in the decoupling of class distribution and energy.
Baselines
Do-nothing reference. A standard cross-entropy model evaluated with the energy OOD score. This is where the file's numbers start: 0% robustness for vanilla ResNet-18 on CIFAR-10 in Do Perceptually Aligned Gradients Imply Robustness?, and an average AUROC of 91.88% for the energy baseline over six OOD sets in the VOS paper.
Robustness and accuracy competitors. Standard adversarial training and TART, run at WideResNet-32-10 on CIFAR-10 with identical epochs, attack steps and learning-rate schedule. TART reports 83.73% clean and 36.58% AutoAttack accuracy, against 81.76% and 35.89% for standard adversarial training. Beating TART means matching its clean accuracy within half a point, while also improving gradient alignment, Max-Sensitivity and OOD AUROC. We do not claim to beat its AutoAttack number under the $\ell_\infty$ threat model. The file indicates that methods which avoid adversarial training trail on that metric: the score-based gradient method reaches only 23.97% $\ell_\infty$ robustness. We will report the gap honestly.
Training-free gradient alignment. The score-based gradient method from the same paper, which reports 55.39% $\ell_2$ robustness on ResNet-18 and needs a pretrained diffusion model. Its clean accuracy appears nowhere in the file, so we will rerun it under our budget. Beating it means comparable $\ell_2$ robustness at ResNet-18 without any diffusion model at training time.
Outlier-free OOD competitors. VOS (94.06% average AUROC on CIFAR-10 versus six OOD sets) and GCOS (93.47% average near-OOD AUROC). Both are retrained on the same backbones with no auxiliary data.
Post-hoc OOD baseline. Extremely Simple Activation Shaping for Out-of-Distribution Detection (ASH), which reaches 22.80% FPR95 on ImageNet with ResNet-50 at roughly 75% accuracy, applied on top of every trained model.
Ablations that isolate the key ingredient.
- Remove the second KL term, so the energy rise can also change the class distribution.
- Remove the hinge term, which leaves pure normal-direction robustness.
- Swap the autoencoder projection for isotropic noise.
All methods share data, augmentation, epoch count and a fixed hyperparameter-search budget of equal trial counts.
Why not just…?
Why not just run adversarial training and add ASH or an energy score at test time? This is the most serious threat. Adversarial training already gives aligned gradients and stable explanations, and ASH needs no outliers. Two problems remain. The combination keeps adversarial training's clean-accuracy loss. And nothing in the file measures OOD detection for adversarially trained models, or tests whether ASH's hard pruning of 90% of late activations breaks gradient-based attributions. We run this combination as a full baseline. If it matches our OOD AUROC and stability at TART-level clean accuracy, the proposal fails.
Why not just use isotropic Gaussian noise, since random directions are almost all off-manifold? This may well work nearly as well, and we treat it as a variant rather than a strawman. It is the isotropic-direction arm of the third study. Two results would separate it from the full method. The first is a worse Max-Sensitivity score, since random pushes are not worst-case within the normal space. The second is weaker near-OOD detection on the GCOS benchmarks, since random shells sit farther from the data than structured ones. If noise matches the full method, the paper's contribution narrows to the decoupling of class distribution and energy. We would report that as the finding.
Why not just smooth explanations post hoc with SmoothGrad? SmoothGrad improves Max-Sensitivity and Infidelity in the sensitivity paper and stability by 12.7% in the relative-stability study. However, it leaves the model at 0% adversarial robustness and does nothing for overconfidence on OOD inputs. It also costs dozens of passes per explanation. We report SmoothGrad on every model, which also tests whether our gains survive smoothing.
Why not just use real outlier exposure? The VOS and GCOS papers document why external outlier data is often unavailable or overlaps the in-distribution classes. Our claim concerns settings without such data. We nonetheless include a web-data outlier exposure run on CIFAR-10 as an upper reference.
Proposed Experiments
The main benchmark is CIFAR-10. We use ResNet-18 for comparison with the gradient-alignment work and WideResNet-32-10 for comparison with TART.
OOD evaluation uses the six far-OOD sets from VOS (Textures, SVHN, Places365, LSUN-crop, LSUN-resize, iSUN). For near-OOD we use the GCOS suite: Stanford Dogs, MVTec AD, Colored MNIST and Retinopathy.
A ResNet-50 on ImageNet tests scale against ASH's iNaturalist, SUN, Places and Textures protocol, if the autoencoder tangent estimate proves tractable there. If it does not, that is itself a reported limitation.
The first decisive check is the direction-split study. If tangent-only training costs more clean accuracy than normal-only training, and normal-only training yields better LPIPS gradient alignment, the conflict between TART and the off-manifold account is resolved in favour of the latter.
The second decisive check is whether the full objective improves OOD AUROC over the energy baseline at no clean-accuracy cost relative to standard training. Removing the second KL term should cause either an accuracy drop or a rise in attribution instability.
The third check asks whether the representation-relative stability gains, not only the input-relative gains, hold up. The relative-stability work shows that input-only stability metrics can be misleadingly optimistic.
References
- Which Models have Perceptually-Aligned Gradients? An Explanation via Off-Manifold Robustness
- TART: Boosting Clean Accuracy Through Tangent Direction Guided Adversarial Training
- Geometrically Constrained Outlier Synthesis
- VOS: Learning What You Don't Know by Virtual Outlier Synthesis
- How Sensitive are Sensitivity-Based Explanations?
- Rethinking Stability for Attribution-based Explanations
- Concise Explanations of Neural Networks using Adversarial Training
- Do Perceptually Aligned Gradients Imply Robustness?
- Extremely Simple Activation Shaping for Out-of-Distribution Detection