Papers
Topics
Authors
Recent
Search
2000 character limit reached

Sharpness-Aware Geometric Defense (SaGD)

Updated 9 July 2026
  • The paper introduces SaGD, a defense framework that smooths the adversarial loss landscape using Riemannian Sharpness-aware Minimization to enhance OOD detection.
  • SaGD employs dual geometric projections—a hypersphere head with vMF-based classification and a hyperbolic head—for learning separable latent embeddings under attack.
  • SaGD integrates Jitter-based adversarial training to keep perturbed ID samples near the manifold, yielding significant improvements in FPR95 and AUC on CIFAR benchmarks.

Sharpness-aware Geometric Defense (SaGD) is a training-time defense and geometry-aware scoring framework for robust out-of-distribution (OOD) detection in the setting where both in-distribution (ID) and OOD samples are subjected to adversarial perturbations. It was introduced to address a failure mode of contemporary geometry-projection OOD detectors: adversarially perturbed ID samples can be pushed far from their class prototype or neighborhood in latent space and are therefore incorrectly flagged as OOD. SaGD smooths the rugged loss landscape induced by adversarial training and learns multi-geometry latent embeddings whose projected structure remains separable for ID, including adversarial ID, versus OOD. Its central components are multi-geometry projection, Riemannian Sharpness-aware Minimization (RSAM), Jitter-based adversarial training, and a nearest-neighbor geometric OOD score in the learned embedding space (Li et al., 24 Aug 2025).

1. Problem setting and motivation

OOD detection is intended to ensure safe and reliable model deployment by distinguishing samples drawn from the training distribution from inputs lying outside it. In geometry-projection OOD detection, a sample is mapped into a latent geometry and scored by distance or density relative to the ID manifold. Under adversarial perturbations, however, an ID image xx can be pushed far from its class prototype or neighborhood in latent space, making its OOD score large. As a result, many geometry-based detectors misclassify adversarial ID as OOD, conflating “maliciously perturbed ID” with “unknown-class OOD” and thereby increasing false positives on adversarial ID (Li et al., 24 Aug 2025).

SaGD is designed for this underexplored but practically critical regime. The stated goal is to distinguish adversarial ID samples from OOD ones rather than treating both as a single rejected category. The motivation rests on the observation that adversarial training, while a strong defense for classification, often sharpens the loss landscape: the inner maximization introduces large gradient norms and increases curvature around local minima, which degrades convergence and stability. In a geometry-projection setting, this appears as unstable latent embeddings, poor prototype compactness, and reduced separability between ID and OOD embeddings, especially under attack (Li et al., 24 Aug 2025).

The framework therefore targets two coupled objectives. First, it seeks to smooth the adversarial loss landscape directly in geometry-projection learning. Second, it seeks to preserve ID compactness and inter-class disparity while maintaining large geometric margins to OOD so that adversarial ID remains near the ID manifold and OOD remains far from it. This suggests that SaGD should be understood not merely as an adversarially trained classifier with an auxiliary detector, but as a joint geometric representation-learning and robust OOD-detection procedure.

2. Multi-geometry latent representation

SaGD uses a backbone encoder and projection heads to learn two latent geometries simultaneously. Let fθf_\theta denote the backbone encoder and heads collectively. Given an input xx, the method extracts a penultimate embedding z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d, which is L2L_2-normalized for scoring, and simultaneously learns two geometry projections (Li et al., 24 Aug 2025).

The first projection is a hypersphere head that produces zsz_s on Sd1S^{d-1} via a vMF-based classifier with class prototypes {μk}\{\mu_k\}. The class-conditional vMF score for unit zsz_s is

pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),

with classification probabilities

fθf_\theta0

Its compactness loss encourages fθf_\theta1 to align with the correct class prototype,

fθf_\theta2

and its disparity loss pushes prototypes apart,

fθf_\theta3

The hypersphere loss is

fθf_\theta4

The second projection is a hyperbolic head that produces fθf_\theta5 on a Poincaré ball fθf_\theta6 with curvature fθf_\theta7, corresponding to constant negative curvature fθf_\theta8. With Möbius operations fθf_\theta9 and geodesic distance

xx0

the supervised hyperbolic contrastive loss on an augmented set xx1 is

xx2

The two geometry heads are combined with cross-entropy in a multi-geometry projection (MGP) objective,

xx3

The stated purpose of this MGP design is to learn richer latent structure than a single geometry. In the formulation of SaGD, that richer structure is intended to improve ID characterization and preserve separability under attack (Li et al., 24 Aug 2025).

3. Sharpness-aware optimization and adversarial example generation

A defining feature of SaGD is the use of Riemannian Sharpness-aware Minimization to regularize adversarial training on the manifold defined by the geometry heads. The framework defines manifold sharpness as

xx4

where xx5 lies on a manifold xx6 with retraction xx7 and metric tensor xx8. Using a first-order approximation,

xx9

the inner maximizer is the normalized Riemannian gradient,

z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d0

The outer update performs Riemannian gradient descent on the perturbed loss,

z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d1

In the method’s interpretation, RSAM flattens sharp minima across the multi-geometry heads, stabilizes latent embeddings, and improves ID/OOD separation under attack. The paper further frames this in gradient-Hessian terms: with adversarial samples z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d2, the gradients z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d3 and z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d4 differ by z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d5, and the curvature term z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d6 appears in the change of feature gradients. Large z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d7 and large z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d8 increase sharpness and harm convergence during adversarial training (Li et al., 24 Aug 2025).

SaGD instantiates adversarial training with Jitter attack rather than standard PGD or FGSM. The standard min-max objective is written as

z=fθ(x)Rdz = f_\theta(x) \in \mathbb{R}^d9

Adversarial examples are generated as L2L_20 with L2L_21, L2L_22, step size L2L_23, and L2L_24 steps. Let L2L_25 be logits, and define

L2L_26

Jitter aims to maximize the distance to the one-hot ground-truth L2L_27 with Gaussian jitter noise L2L_28 injected into the softmax output:

L2L_29

Its adaptive perturbation rule is

zsz_s0

where zsz_s1 reduces perturbation magnitude once the attack is effective. The stated reason is to keep adversarial examples close to the ID manifold and prevent distribution shift that could harm embedding learning. Empirically, Jitter-based adversarial training is reported to generalize better to unseen attacks than training based on standard PGD or FGSM (Li et al., 24 Aug 2025).

4. OOD scoring, training algorithm, and implementation choices

After training, SaGD constructs an ID embedding bank from penultimate-layer features and scores a test sample by nearest-neighbor geometric distance. With normalized embedding zsz_s2 from the penultimate layer, the OOD score is

zsz_s3

where zsz_s4 is the zsz_s5-th nearest neighbor among ID training embeddings. A threshold zsz_s6 determines OOD versus ID. In the main experiments, zsz_s7 is taken as the nearest neighbor. The method reports that this score is empirically robust, computationally simple, and more stable than alternatives adopted in some baselines, such as Mahalanobis variants (Li et al., 24 Aug 2025).

The training procedure comprises adversarial example generation, joint geometry learning, and RSAM optimization. For each minibatch, adversarial examples are first generated via Jitter with Gaussian softmax jitter and adaptive factor zsz_s8. Clean and adversarial inputs are then forwarded through the backbone and geometry heads to produce zsz_s9, Sd1S^{d-1}0, and penultimate Sd1S^{d-1}1. The multi-geometry loss is computed, followed by an RSAM inner step that computes the Riemannian gradient, perturbs parameters within a tangent-ball of radius Sd1S^{d-1}2, retracts to Sd1S^{d-1}3, and evaluates the worst-case loss. An RSAM outer step then updates the parameters via retraction-based gradient descent on that worst-case loss. At inference time, the ID embedding bank is built from L2-normalized penultimate features, and threshold calibration is performed on a held-out ID set, optionally with a small validation OOD set, to report FPR@95%TPR, AUROC, and AUPR (Li et al., 24 Aug 2025).

The implementation details reported for the main experiments are specific. CIFAR-10 uses ResNet-18, and CIFAR-100 uses ResNet-34. Optimization uses SGD with momentum Sd1S^{d-1}4, weight decay Sd1S^{d-1}5, initial learning rate Sd1S^{d-1}6, and RSAM regularization. Training lasts Sd1S^{d-1}7 epochs with batch size Sd1S^{d-1}8, penultimate dimension Sd1S^{d-1}9, and hyperbolic curvature {μk}\{\mu_k\}0. Feature clipping of the form {μk}\{\mu_k\}1 is applied to stabilize training near the ball boundary. Attacks considered in training and evaluation include PGD, FGSM, FAB, Jitter, and CW via TorchAttacks, all with {μk}\{\mu_k\}2, step size {μk}\{\mu_k\}3, and {μk}\{\mu_k\}4 steps; additional evaluation includes APGD-100, APGD-1000, and AutoAttack (Li et al., 24 Aug 2025).

The paper also provides practical tuning guidance. It recommends Jitter-based adversarial training for robustness to unseen attacks; small RSAM radii, exemplified by {μk}\{\mu_k\}5 relative to gradient norms; curvature {μk}\{\mu_k\}6 for stability; temperatures {μk}\{\mu_k\}7 for vMF and contrastive losses; and small {μk}\{\mu_k\}8 in k-NN, with {μk}\{\mu_k\}9 in the main scoring. RSAM is reported to roughly double the per-iteration cost compared to vanilla SGD, since it requires one extra forward/backward pass at zsz_s0 plus retraction, while Jitter adversarial generation adds zsz_s1 inner steps per batch (Li et al., 24 Aug 2025).

5. Empirical evaluation

The experimental setup uses CIFAR-10 and CIFAR-100 as ID datasets and six OOD datasets: Tiny-ImageNet, Places365, LSUN, LSUN-Resize, iSUN, and Textures. For ATD and ATOM, which are exposure-based baselines, Food-101 is used for auxiliary outlier training and SVHN for validation, following their protocols. The primary metrics are FPR@95%TPR (FPR95) and AUROC, with additional reporting of Inlier AUC and Outlier AUC (Li et al., 24 Aug 2025).

The main reported quantitative results are averages over the six OOD datasets. For CIFAR-10 ID, without adversarial training, MGP-Mahalanobis achieves FPR95 zsz_s2 and AUC zsz_s3, and KNN+, ASH, ODIN, and GODIN are reported to degrade significantly under attacks. With adversarial training, ATOM obtains FPR95 zsz_s4 and AUC zsz_s5, ATD obtains FPR95 zsz_s6 and AUC zsz_s7, and SaGD obtains FPR95 zsz_s8 and AUC zsz_s9. The gains over ATD are reported as pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),0 FPR95 and pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),1 AUC. Per-condition results for SaGD on CIFAR-10 are: Clean pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),2, PGD pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),3, Jitter pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),4, FAB pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),5, FGSM pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),6, and CW pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),7 (Li et al., 24 Aug 2025).

For CIFAR-100 ID, without adversarial training, CIDER-Maha reports FPR95 pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),8 and AUC pd(zs;μk)=τexp(μkzsτ),p_d(\mathbf{z}_s;\boldsymbol{\mu}_k) = \tau\,\exp\Big(\frac{\boldsymbol{\mu}_k^\top\mathbf{z}_s}{\tau}\Big),9, while MGP-KNN reports FPR95 fθf_\theta00 and AUC fθf_\theta01. With adversarial training, ATOM reports FPR95 fθf_\theta02 and AUC fθf_\theta03, ATD reports FPR95 fθf_\theta04 and AUC fθf_\theta05, and SaGD reports FPR95 fθf_\theta06 and AUC fθf_\theta07. The gains over ATD are fθf_\theta08 FPR95 and fθf_\theta09 AUC, and the gains over ATOM are fθf_\theta10 FPR95 and fθf_\theta11 AUC (Li et al., 24 Aug 2025).

On CIFAR-10 under adaptive attacks, the average adversarial results over five attacks are ATD: FPR95 fθf_\theta12, AUC fθf_\theta13, AUCIn fθf_\theta14, AUCOut fθf_\theta15; and SaGD: FPR95 fθf_\theta16, AUC fθf_\theta17, AUCIn fθf_\theta18, AUCOut fθf_\theta19. Under APGD-100, ATD reports fθf_\theta20 versus SaGD fθf_\theta21; under APGD-1000, ATD reports fθf_\theta22 versus SaGD fθf_\theta23; and under AutoAttack, ATD reports fθf_\theta24 versus SaGD fθf_\theta25 (Li et al., 24 Aug 2025).

Setting Comparator SaGD
CIFAR-10 average over six OOD datasets ATD: 42.59 / 87.36 27.68 / 94.83
CIFAR-100 average over six OOD datasets ATD: 67.58 / 77.41 49.87 / 87.59
CIFAR-10 AutoAttack ATD: 47.95 / 83.86 32.18 / 93.01

The table entries are FPR95 / AUC. The reported pattern is that SaGD improves both false-positive behavior and ranking quality across clean, standard adversarial, and adaptive attack settings. A plausible implication is that the method improves both separability and score calibration in robust OOD detection, although the paper itself states this more directly in terms of reduced FPR and increased AUC (Li et al., 24 Aug 2025).

6. Ablations, interpretation, and limitations

The ablation study on CIFAR-10 isolates the contributions of RSAM and Jitter. MGP + Jitter without RSAM achieves average FPR95 fθf_\theta26 and AUC fθf_\theta27. MGP + RSAM without Jitter achieves average FPR95 fθf_\theta28 and AUC fθf_\theta29, which the paper interprets as evidence that sharpness reduction alone without adversarial training is insufficient. CIDER + RSAM + Jitter achieves average FPR95 fθf_\theta30 and AUC fθf_\theta31, indicating that both RSAM and Jitter help even with single-geometry heads. SaGD, combining MGP + RSAM + Jitter, achieves the best result: average FPR95 fθf_\theta32 and AUC fθf_\theta33 (Li et al., 24 Aug 2025).

A separate ablation shows that the choice of adversarial training attack matters. RSAM+PGD training yields average FPR95 fθf_\theta34 and AUC fθf_\theta35 but is very strong on FGSM, with FPR95 fθf_\theta36 and AUC fθf_\theta37, indicating overfitting to attack type. RSAM+FAB yields average FPR95 fθf_\theta38 and AUC fθf_\theta39; RSAM+FGSM yields average FPR95 fθf_\theta40 and AUC fθf_\theta41; and RSAM+CW yields average FPR95 fθf_\theta42 and AUC fθf_\theta43. The reported conclusion is that Jitter-based adversarial training generalizes better across attack families than these alternatives (Li et al., 24 Aug 2025).

The paper also studies attack intensity sensitivity under PGD on CIFAR-10. Increasing fθf_\theta44 from fθf_\theta45 to fθf_\theta46 is reported to double FPR95 and reduce AUC by approximately fθf_\theta47. SaGD is described as remaining relatively stable in AUROC while FPR95 is more sensitive, which the authors use to reinforce the importance of reporting FPR@95%TPR in robust OOD detection (Li et al., 24 Aug 2025).

Visualization results further support the method’s interpretation. Histograms of fθf_\theta48 for ID versus OOD under clean and adversarial settings, specifically FGSM and FAB, show that SaGD maintains clear separation, while MGP without defense and CIDER-RSAM-Jitter collapse under FGSM and FAB. RSAM+PGD yields distinct peaks only against PGD but fails on FAB, again illustrating overfitting of standard adversarial training to the seen attack (Li et al., 24 Aug 2025).

The limitations and deployment guidance are stated with similar specificity. FGSM remains a relatively challenging case because of its single-step, large-direction perturbations, although SaGD still improves AUROC and maintains separability. Stronger attacks with larger fθf_\theta49 increase FPR, so both FPR95 and AUROC should be reported. The framework is recommended for systems in which adversarial ID must be kept as ID while OOD rejection is also required, such as safety-critical gating or triage. It is also presented as advantageous when outlier exposure is impractical, because it avoids dependence on large auxiliary OOD datasets while outperforming exposure-based baselines ATD and ATOM in the reported experiments (Li et al., 24 Aug 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Sharpness-aware Geometric Defense (SaGD).