Robust and generalizable classification

Revisit the hardest samples. Correct them. Train on them.

Self-Adaptive Revisiting Awareness for Enhancing Robustness and Generalization in Classification Tasks

Mohammad Khalooei, Maryam Amirmazlaghani, Mohammad Mehdi Homayounpour

Department of Computer Engineering, Amirkabir University of Technology, Tehran, Iran
Try a correction Click anywhere

true class other class accepted discarded
+1.8ptsAutoAttack accuracy that the acceptance test adds on CIFAR10 (3 seeds, McNemar p = 2·10−8)
3/ 3seeds with lower calibration error under attack than PGD training, CIFAR10 and SVHN
0.00ptsaccuracy removed by the black-box Square attack after AutoAttack: no gradient masking
4proven properties, the alignment bound verified on 3,529 accepted corrections

Overview

The decision boundary is learned where the model is least certain

Deep networks are vulnerable to small input perturbations, and the samples near the decision boundary carry most of that risk. SARA revisits them while training. In every iteration it finds the misclassified and low-confidence samples of the mini-batch, moves each one to a nearby point that the current model classifies correctly with sufficient confidence and margin, and adds every successful correction to the batch. The correction follows a new loss, the Confidence Guard loss, and SARA works on top of standard training or of adversarial training.

Loss

Confidence Guard loss

A cross-entropy pull toward the true class plus a hinge penalty on the margin. It bounds the misclassification error and encodes the acceptance criterion exactly.

Integration

A plug-in for adversarial training

SARA wraps the base loss of standard training or of PGD, TRADES, MART and LSA adversarial training without changing it.

Robustness

As robust as PGD training, under AutoAttack

With the standard ResNet18 at ε = 8/255 and three seeds, SARA keeps the AutoAttack accuracy of adversarial training and lowers its calibration error under attack on every seed.

Theory

A provable inner correction

The correction converges under a standard smoothness assumption, and every accepted sample certifies a robust neighborhood.

Scale

A class-count-relative threshold

The confidence threshold is set relative to chance level, ξ · 10 / C, so the acceptance criterion stays meaningful on CIFAR100 and Tiny-ImageNet-200.

Alignment

Corrections as targets

Each accepted correction becomes a fixed target for the adversarial prediction of the same sample, a term that stays active after acceptance and has a provable bound.

Method

One training iteration

SARA adds an inner correction to each mini-batch and a second term to the training objective. Everything else in the training loop stays as it is.

the original batch B always enters the loss Mini-batch B from the training set Identify S misclassified or confidence below ξ Correct κ projected steps on L_CG inside the ε-box Accept S* f_y ≥ ξ and margin ≤ −τ Update θ Loss_base(B) + β · Align(S*) ONE TRAINING ITERATION
Challenging setS = {(x, y) ∈ B : argmaxj fj(x) ≠ y or fy(x) < ξ}
Marginh(x, y) = maxj≠y fj(x) − fy(x)
Confidence Guard lossLCG(x, y) = CE(f(x), y) + λmargin · ReLU(h(x, y) + τ)
Inner updateδ ← ΠΔ(δ − α ∇δ LCG(x + δ, y)), Δ = {δ : ‖δ‖∞ ≤ ε, x + δ ∈ [0, 1]d}
AlignmentAlign(S*) = (1/|B|) Σs∈S* KL(f(x*s) ‖ f(xadvs)), with f(x*s) held fixed
Outer objectiveLossSARA = Lossbase(B) + LossCG,cap(S*) + β · Align(S*)

Evidence

Measured under the standard protocol

ResNet18 with a 3×3 stem, ε = 8/255, PGD-10 training, weight averaging, three seeds with identical initializations and mini-batches, and every SARA setting chosen on a validation split. AutoAttack runs all four stages on 2,000 test images.

MethodCleanPGD-20AutoAttackCalibration error under PGD-20Cost
CIFAR10, 30 epochs
AT-PGD80.5249.9546.808.541.00×
AT-PGD + SARA80.2749.9246.787.721.45×
SARA without acceptance test78.2249.2645.001.781.49×
SVHN, 20 epochs
AT-PGD90.9149.4941.3816.841.00×
AT-PGD + SARA91.0049.8941.2714.841.35×
SARA without acceptance test90.9850.5041.1313.281.35×

Accuracies and calibration error in %, means over three seeds; calibration error before temperature scaling. SARA matches the robustness of PGD adversarial training on both datasets. On CIFAR10, removing the acceptance test costs 2.1 points of clean and 1.8 points of AutoAttack accuracy on every seed; on SVHN it changes neither. Training AT-PGD for as long as SARA takes lowers its own robustness. Per-image McNemar tests, temperature-scaled calibration, L2 and corruption results are in Appendix D of the paper and in the released records.

Tuned protocol

With the hyperparameters of each method tuned individually (Table 3 of the paper), adding SARA raised the robust accuracy of all five base methods. The paper's controlled study attributes most of these margins to per-method tuning and training settings.

Change from adding SARA, in percentage points

Robust accuracy with and without SARA

base method with SARA

Ranking by mean robust accuracy

    Mean over the strongest reported attack per dataset: APGD with ε = 0.2 on MNIST and ε = 0.03 on CIFAR10 and SVHN.

    How these numbers were obtained. The charts above show the tuned protocol (Tables 3 and 19 of the paper). The run records of every controlled and standard-protocol experiment are in the results directory.

    Theory

    Guarantees behind the correction

    Proposition 1

    Convergence

    Every iterate stays in the admissible set. Under a standard smoothness assumption, the Confidence Guard loss decreases monotonically and the correction reaches an approximate stationary point at rate O(1/K).

    Proposition 2

    Consistency

    The Confidence Guard loss upper-bounds the misclassification indicator, and its two terms encode the confidence and margin conditions of the acceptance region exactly.

    Proposition 3

    Certified neighborhood

    Under the current model, an accepted sample is surrounded by a ball of radius min{r, τ / Lh} on which the prediction does not change.

    Proposition 4

    Alignment

    If the adversarial prediction is within KL divergence η of the accepted correction, its confidence and margin fall short of the acceptance criterion by at most √(η/2) and √(2η).

    Interpretation

    Vicinal risk minimization

    The outer objective adds to the empirical risk a model-dependent vicinity that is concentrated near the decision boundary.

    Code

    Install and train

    The repository contains the method, the GAIRAT, FAT and OHEM baselines, the scripts of every experiment, and unit tests. MNIST, CIFAR10, CIFAR100 and SVHN download automatically.

    Command line
    git clone https://github.com/khalooei/SARA.git
    cd SARA && pip install -e .
    
    python train.py --dataset cifar10 --model resnet18-cifar \
        --base-loss pgd --at-epsilon 0.031373 --pgd-steps 10 \
        --sara --sara-align 3 --xi 0.2 --sara-max-correct 64 \
        --cg-confidence-cap --ema-decay 0.999 --epochs 30 \
        --eval-apgd --eval-autoattack 1000 --out-dir runs/cifar10/sara
    Python
    from sara import SARAConfig, build_base_loss, sara_training_step
    
    base_loss = build_base_loss("pgd")   # ce, pgd, trades, mart
    cfg = SARAConfig(epsilon=8/255, xi=0.2, kappa=10, max_batch_correct=64,
                     cg_confidence_cap=True, align_weight=3.0)
    
    for x, y in train_loader:
        stats = sara_training_step(model, optimizer, x, y,
                                   base_loss, cfg,
                                   base_loss_kwargs={"pgd_steps": 7})

    Citation

    Cite this work

    BibTeX
    @misc{khalooei2026sara,
      title  = {Self-Adaptive Revisiting Awareness for Enhancing Robustness
                and Generalization in Classification Tasks},
      author = {Khalooei, Mohammad and Amirmazlaghani, Maryam
                and Homayounpour, Mohammad Mehdi},
      year   = {2026},
      howpublished = {\url{https://github.com/khalooei/SARA}}
    }