Confidence-Calibrated Adversarial Training and Detection: More Robust Models Generalizing Beyond the Attack Used During Training

David Stutz, Matthias Hein, Bernt Schiele

Abstract

Adversarial training is the standard to train models robust against adversarial examples. However, especially for complex datasets, adversarial training incurs a significant loss in accuracy and is known to generalize poorly to stronger attacks, e.g., larger perturbations or other threat models. In this paper, we introduce confidence-calibrated adversarial training (CCAT) where the key idea is to enforce that the confidence on adversarial examples decays with their distance to the attacked examples. We show that CCAT preserves better the accuracy of normal training while robustness against adversarial examples is achieved via confidence thresholding, i.e., detecting adversarial examples based on their confidence. Most importantly, in strong contrast to adversarial training, the robustness of CCAT generalizes to larger perturbations and other threat models, not encountered during training. For evaluation, we extend the commonly used robust test error to our detection setting, present an adaptive attack with backtracking and allow the attacker to select, per test example, the worst-case adversarial example from multiple black- and white-box attacks. We present experimental results using $L_\infty$, $L_2$, $L_1$ and $L_0$ attacks on MNIST, SVHN and Cifar10.

Introduction

The current gold standard for defending deep neural networks is Adversarial Training (AT). In this paradigm, models are trained on adversarial examples generated on-the-fly, with the objective of forcing the model to classify these distorted inputs correctly with high confidence. While effective within the specific threat model used during training, AT suffers from two major drawbacks: a significant drop in clean test accuracy and poor generalization to unseen attack types (e.g., different $L_p$ norms or larger perturbations).

The authors of this paper propose a fundamental shift: instead of trying to correctly classify every malicious input, models should be trained to detect them by becoming increasingly uncertain as the input moves further from the training distribution.

Methodology: Confidence-Calibrated Adversarial Training (CCAT)

The core innovation is Confidence-Calibrated Adversarial Training (CCAT). Unlike standard AT, which enforces a hard label on adversarial examples, CCAT assigns a target distribution that is a mixture of the correct label and a uniform distribution (representing total uncertainty).

As the perturbation distance ($\delta$) from the original image increases, the model is forced toward this uniform distribution. This ensures that the model's confidence naturally decays as the input becomes more distorted. At test time, the model can detect adversarial attacks by applying a threshold ($\tau$) to the maximum confidence score; inputs falling below this threshold are rejected.

Confidence decay in CCAT vs. standard AT. In CCAT (right), confidence in all classes converges to a uniform distribution as perturbation distance increases, whereas AT (left) simply flips confidence to an incorrect class.

To ensure the defense is robust against attackers who know the detection mechanism, the authors introduced PGD-Conf, an adaptive attack that specifically attempts to maximize the model's confidence in any incorrect class to bypass the threshold.

Key Results and Generalization

CCAT demonstrates a remarkable ability to generalize to attack types not encountered during training. By learning a general rule—that distance from the data manifold equals low confidence—a model trained only on $L_\infty$ attacks becomes capable of detecting $L_2, L_1,$ and $L_0$ attacks as well.

On the SVHN dataset, a standard AT model trained on $L_\infty$ exhibits a robust test error of 92% against $L_2$ attacks. In contrast, CCAT reduces this error to just 18.5%. Furthermore, CCAT maintains clean test accuracy much closer to naturally trained models compared to standard AT.

Confidence distributions for AT and CCAT. While both models maintain high confidence on clean test data (top), CCAT significantly reduces confidence on adversarial examples (bottom right), providing a clear signal for detection that standard AT (bottom left) lacks.

Discussion and Limitations

CCAT represents a philosophical shift toward well-calibrated uncertainty in AI safety. However, it introduces a trade-off: the "reject" option. In critical applications like autonomous driving, simply identifying an input as adversarial may not be sufficient if a correct classification is required for safety. Additionally, the performance of CCAT is sensitive to the choice of transition functions and decay rates, which currently require manual tuning for different datasets. Future work may focus on automating these hyperparameters and scaling the approach to larger datasets like ImageNet.

Summary updated

Abstract

Adversarial training is the standard to train models robust against adversarial examples. However, especially for complex datasets, adversarial training incurs a significant loss in accuracy and is known to generalize poorly to stronger attacks, e.g., larger perturbations or other threat models. In this paper, we introduce confidence-calibrated adversarial training (CCAT) where the key idea is to enforce that the confidence on adversarial examples decays with their distance to the attacked examples. We show that CCAT preserves better the accuracy of normal training while robustness against adversarial examples is achieved via confidence thresholding, i.e., detecting adversarial examples based on their confidence. Most importantly, in strong contrast to adversarial training, the robustness of CCAT generalizes to larger perturbations and other threat models, not encountered during training. For evaluation, we extend the commonly used robust test error to our detection setting, present an adaptive attack with backtracking and allow the attacker to select, per test example, the worst-case adversarial example from multiple black- and white-box attacks. We present experimental results using $L_\\infty$, $L_2$, $L_1$ and $L_0$ attacks on MNIST, SVHN and Cifar10.
BibTeX
@inproceedings{stutz2020confidence,
  author = {David Stutz and Matthias Hein and Bernt Schiele},
  title = {{Confidence-Calibrated Adversarial Training and Detection: More Robust Models Generalizing Beyond the Attack Used During Training}},
  booktitle = {International Conference on Machine Learning},
  year = {2020},
}
Figure