Adversarial training (AT) remains the gold standard for defending deep learning models against adversarial attacks. However, its high computational cost is a significant barrier, particularly for Vision Transformers (ViTs). The self-attention mechanism in ViTs scales quadratically with the number of input patches, making AT prohibitively slow. This paper introduces Attention Guided Adversarial Training (AGAT), a novel method that reduces training time by approximately 35% while maintaining or improving robustness.
The Challenge: Efficiency and Stability in ViT Training
Vision Transformers are susceptible to adversarial examples—small, intentional perturbations that lead to misclassification. While AT can mitigate this, it is computationally expensive. Furthermore, applying efficient variants like "Fast AT" to large ViTs often results in catastrophic overfitting, where the model's robustness suddenly collapses during training. Interestingly, larger models in the same family do not always yield better robustness; for instance, CaiT-S36 can perform worse than its smaller counterparts under standard Fast AT.
Attention Guided Adversarial Training (AGAT)
AGAT addresses these issues by leveraging the inherent ability of Transformers to process variable-length sequences. The core mechanism involves identifying and dropping "unimportant" image patches during the training process.
The process follows four key steps:
- Attention-Guided Dropping: AGAT uses existing attention scores to rank patch importance. By summing attention rows, the model identifies which patches most influence the final output.
- Selective Pruning: Patches with low scores—typically representing background or non-essential details—are discarded. This reduces the workload for subsequent self-attention and MLP modules.
- Layer-wise Exponential Dropping: Recognizing that redundancy increases in deeper layers, AGAT progressively reduces the sequence length as data moves through the network.
- Training-Only Regularization: Patch dropping occurs only during training. This not only saves time but also acts as a powerful regularizer, preventing the robustness collapse seen in larger models. During inference, the full image is processed to ensure maximum accuracy.
Key Results and Performance
The researchers evaluated AGAT on the ImageNet dataset across various ViT families, including standard ViT, CaiT, and LeViT.
The results demonstrate significant improvements in both efficiency and robustness:
- Speed and Efficiency: AGAT achieves a 35% reduction in training time and saves over 40% of total FLOPs for a ViT-Base model.
- Enhanced Robustness: In many cases, AGAT outperforms the baseline. For example, on ViT-Base, AGAT reached 51.23% PGD-20 accuracy, surpassing the 50.55% achieved by standard Fast AT.
- Stability: By acting as an architectural regularizer, AGAT effectively eliminates catastrophic overfitting in large-scale ViTs, ensuring stable and reliable adversarial training.
Conclusion
AGAT proves that building robust Vision Transformers does not require processing every pixel at every step. By focusing on salient features guided by attention, AGAT offers a more efficient and stable path toward robust computer vision models. Future work may extend this approach to more complex attention mechanisms like window-based or multi-scale attention.
Summary updated