Improving the Robustness of Deep Neural Networks via Adversarial Training with Triplet Loss

Pengcheng Li, Jinfeng Yi, Bowen Zhou, Lijun Zhang

Abstract

Deep Neural Networks (DNNs) are notoriously vulnerable to adversarial examples—small, imperceptible perturbations that trigger incorrect classifications. While Adversarial Training (AT) is a standard defense, it often distorts classification boundaries, leaving models susceptible to unseen attacks. This paper introduces Adversarial Training with Triplet Loss ($AT^2L$), a novel approach that leverages distance metric learning to smooth decision boundaries. By using adversarial examples as anchors in a triplet loss framework, $AT^2L$ creates a more stable embedding space, significantly enhancing robustness against both known and unknown attacks without sacrificing accuracy on clean data.

Introduction

The fragility of DNNs poses a significant barrier to their deployment in security-critical applications. Traditional Adversarial Training (AT) incorporates adversarial examples into the training set to minimize cross-entropy loss. However, this localized optimization does not guarantee that the surrounding embedding space is well-behaved. Consequently, models often remain vulnerable to "transferred" attacks or different attack algorithms. We propose $AT^2L$ to address this by explicitly regularizing the distance between adversarial examples and their clean counterparts.

Methodology

The $AT^2L$ Algorithm

The core innovation of $AT^2L$ is the integration of Triplet Loss into the adversarial training pipeline. In a standard triplet loss, the model minimizes the distance between an anchor and a positive sample while maximizing the distance to a negative sample. $AT^2L$ redefines the triplet components to target boundary stability:

  1. Anchor: The adversarial example ($x^{adv}$).
  2. Positive: The original, clean version of the anchor image ($x$).
  3. Negative: A clean image from a different class ($x^n$).

By minimizing this loss, the network is forced to pull adversarial examples toward their true class identity in the embedding space, effectively "smoothing" the decision boundary where it is most brittle.

Ensemble and Regularization

To defend against unknown attacks, we developed an Ensemble $AT^2L$ that aggregates adversarial examples from multiple attack methods (e.g., FGSM, C&W) and architectures. Furthermore, the $AT^2L$ objective can function as a modular Triplet Regularization term ($R(x, y)$), which can be added to other defense frameworks like Thermometer Encoding or Defense-GAN to enhance their baseline performance.

Experimental Evaluation

We evaluated $AT^2L$ on three benchmark datasets: Cats vs. Dogs (binary classification), MNIST (handwritten digits), and CIFAR10 (object recognition). The models were tested against various attack vectors to measure error rate stability over training iterations.

Comparative error rates of standard Adversarial Training (Adv.T) versus the proposed $AT^2L$ across three datasets.

Results and Discussion

Empirical results demonstrate that $AT^2L$ consistently outperforms standard adversarial training across all benchmarks:

  • Robustness Gains: On the Cats vs. Dogs dataset, $AT^2L$ achieved an error rate of 8.3% against FGSM attacks, a significant improvement over the 11.6% error rate of traditional AT.
  • Synergistic Effects: When used as a regularizer for Thermometer Encoding on CIFAR10, the error rate against FGSM attacks dropped from 20.0% to 15.1%.
  • Boundary Stability: As shown in the experimental figures, $AT^2L$ variants (solid lines) maintain lower and more stable error rates across training iterations compared to standard Adv.T (dotted lines).
  • Clean Accuracy: Crucially, the smoothing effect of the triplet loss does not degrade performance on clean, non-adversarial data, overcoming a common trade-off in robust optimization.

Conclusion

Adversarial Training with Triplet Loss ($AT^2L$) provides a robust framework for securing DNNs by focusing on embedding space stability rather than simple point-wise fitting. By treating adversarial examples as probes for boundary weakness, $AT^2L$ achieves superior generalization against diverse attack types. Future work will focus on optimizing the computational cost of triplet sampling and scaling the method to massive datasets like ImageNet.

Summary updated

BibTeX
@inproceedings{li2019improving,
  author = {Pengcheng Li and Jinfeng Yi and Bowen Zhou and Lijun Zhang},
  title = {{Improving the Robustness of Deep Neural Networks via Adversarial Training with Triplet Loss}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.24963/ijcai.2019/403},
}
Figure