Alleviating the Effect of Data Imbalance on Adversarial Training

Guanlin Li, Guowen Xu, Tianwei Zhang

TL;DR

Adversarial training typically breaks down when applied to real-world, long-tailed (highly imbalanced) datasets because models generate uneven adversarial examples and suffer from compressed feature spaces for tail classes. This paper introduces Re-balancing Adversarial Training (REAT), a framework that uses an adaptive class-weighting loss and feature margin regularization to significantly boost both clean accuracy and adversarial robustness on imbalanced data without relying on easily bypassed gradient obfuscation tricks.

What Problem Does This Paper Address?

Deep learning models are notoriously vulnerable to adversarial attacks—small, imperceptible perturbations designed to fool them. While adversarial training (generating adversarial examples on-the-fly and adding them to the training set) is the gold standard for defense, it assumes the training data is perfectly balanced.

Real-world data, however, is usually "long-tailed," meaning a few "head" classes have tons of samples, while many "tail" classes have very few. When you run standard adversarial training on long-tailed data, two major dilemmas emerge:

  1. Uneven Adversarial Examples (AEs): The generated AEs are overwhelmingly misclassified into the dominant head classes, meaning the model rarely practices defending tail classes during training.
  2. Unbalanced Feature Space: Head classes crowd out the feature embedding space, leaving very little room for tail classes, which severely degrades both their clean accuracy and robust accuracy.
Figure 1. Prediction distributions of AEs. Clean label distributions are shown by gray bars.

Prior work (like RoBal) tried to fix this but relied on a scale-invariant layer that caused gradient vanishing, making it highly vulnerable to simple adaptive attacks. It also ignored "body" classes (the middle ground between head and tail), hurting overall model utility.

Methods

The authors propose REAT, a framework that tackles both the data generation and feature space dilemmas through two novel components:

  • Re-Balanced Loss (RBL) for AE Generation: Inspired by the concept of "effective number" in long-tailed recognition, RBL dynamically adjusts class weights during the adversarial attack phase. If too many AEs are being classified into a specific class (like a head class) in the previous epoch, RBL penalizes that class in the current epoch. This forces the generator to produce more diverse, informative AEs distributed across tail classes.
  • Tail-sample-mining-based feature margin regularization (TAIL): To fix the feature space imbalance, TAIL treats tail samples as "hard samples." It maps features into a probabilistic embedding space and uses a regularization term based on Kullback-Leibler Divergence (KLD). It maximizes the distance between tail classes and other classes while minimizing the distance between samples of the same tail class, effectively expanding the territory of tail classes in the feature space.
Figure 2. Visualization of feature maps of AEs from models.

Datasets

The authors evaluated REAT using standard long-tailed benchmarks:

  • CIFAR-10-LT and CIFAR-100-LT: Long-tailed variants of standard CIFAR datasets, created by artificially downsampling classes using an imbalance ratio (UR) ranging from 10 to 100.
  • Tiny-Imagenet: A downsampled real-world dataset used to evaluate the framework's scalability to more complex, realistic scenarios.

Key Insights and Ideas

  • The Illusion of Robustness via Gradient Obfuscation: The authors discovered that the leading baseline, RoBal, didn't actually create a robust model; its defense relied heavily on gradient vanishing in its classification layer. By simply multiplying the output logits by a constant factor (an adaptive attack), RoBal's defense collapsed. REAT avoids this trap by ensuring true adversarial robustness without obfuscating gradients.
  • Don't Forget the Body: Previous methods focused exclusively on the extremes (head vs. tail), which inadvertently tanked the performance on intermediate "body" classes. REAT treats the distribution more holistically, yielding much better overall accuracy.
  • Data Unbalance vs. Data Hunger: Through ablation studies, the authors showed that the unbalance of data harms adversarial robustness far more than the sheer scarcity (hunger) of data alone.

Key Results

  • Superior Robustness: On CIFAR-10-LT (with an imbalance ratio of 50) using a ResNet-18 architecture, REAT achieved 67.33% clean accuracy and 32.08% robust accuracy under AutoAttack, outperforming RoBal (which drops significantly under adaptive attacks).
  • Strong Generalization: REAT consistently beats standard PGD-AT across various long-tailed loss functions (Focal Loss, LDAM, Balanced Softmax Loss), demonstrating excellent compatibility with existing long-tailed recognition techniques.
  • Better Feature Separation: Visualizations (via t-SNE) confirm that REAT successfully prevents tail class features from being crowded out by head classes, creating a well-separated, balanced feature space.

Limitations and Future Work

Despite the improvements, a noticeable robustness gap still remains between models trained on perfectly balanced datasets and those trained on long-tailed datasets. Tail classes inherently suffer from a lack of data, making high robustness exceptionally difficult to achieve. The authors note that exploring novel network architectures specifically tailored for long-tailed adversarial defense is a vital direction for future work.

Summary updated

Abstract

In this paper, we study adversarial training on datasets that obey the long-tailed distribution, which is practical but rarely explored in previous works. Compared with conventional adversarial training on balanced datasets, this process falls into the dilemma of generating uneven adversarial examples (AEs) and an unbalanced feature embedding space, causing the resulting model to exhibit low robustness and accuracy on tail data. To combat that, we theoretically analyze the lower bound of the robust risk to train a model on a long-tailed dataset to obtain the key challenges in addressing the aforementioned dilemmas. Based on it, we propose a new adversarial training framework -- Re-balancing Adversarial Training (REAT). This framework consists of two components: (1) a new training strategy inspired by the effective number to guide the model to generate more balanced and informative AEs; (2) a carefully constructed penalty function to force a satisfactory feature space. Evaluation results on different datasets and model structures prove that REAT can effectively enhance the model's robustness and preserve the model's clean accuracy. The code can be found in https://github.com/GuanlinLee/REAT.
BibTeX
@misc{li2023alleviating,
  author = {Guanlin Li and Guowen Xu and Tianwei Zhang},
  title = {{Alleviating the Effect of Data Imbalance on Adversarial Training}},
  year = {2023},
  eprint = {2307.10205},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.10205},
}
Figure