Abstract
Vision Transformers (ViTs) have demonstrated remarkable success in global context modeling but often lag behind Convolutional Neural Networks (CNNs) in capturing fine-grained local details. This paper identifies a fundamental "frequency gap" between these architectures: while CNNs naturally emphasize high-frequency components like edges and textures, the self-attention mechanism in ViTs acts as a low-pass filter, smoothing out critical local information. To bridge this gap, the authors propose High-frequency Adversarial Training (HAT). By leveraging adversarial perturbations—which are predominantly high-frequency—HAT forces ViTs to attend to missing spectral details. The resulting models show significant improvements in both clean accuracy and robustness across multiple benchmarks, including a 1.2% gain for ViT-B on ImageNet-1K.
The Frequency Gap in Vision Transformers
The transition from CNNs to ViTs marked a shift from local receptive fields to global self-attention. However, this shift came with a trade-off. Through Discrete Fourier Transform (DFT) analysis, the authors demonstrate that ViTs and CNNs exhibit divergent spectral behaviors. CNNs typically act as high-pass filters, prioritizing sharp transitions and edges. In contrast, the cascading self-attention layers in ViTs function as low-pass filters, progressively smoothing the image representation. This "nearsightedness" regarding high-frequency data explains why ViTs often require larger datasets or heavy augmentation to match CNN performance on tasks requiring fine-grained detail.
High-frequency Adversarial Training (HAT)
To address this spectral deficiency, the researchers introduced HAT. The core idea is to use adversarial training not just for security, but as a targeted data augmentation strategy to improve general performance.
- Spectral Motivation: Adversarial perturbations generated via Projected Gradient Descent (PGD) are naturally concentrated in the high-frequency domain.
- The HAT Mechanism: By training ViTs to correctly classify these high-frequency adversarial examples, the model is effectively forced to "pay attention" to the spectral regions it usually ignores.
- Optimization: To mitigate the computational cost of PGD, the authors employ a gradient accumulation strategy that updates model weights and perturbations simultaneously. To further improve efficiency, the adversarial phase is restricted to the initial 200 epochs of the training cycle.
Experimental Results
The HAT framework was evaluated on ImageNet-1K and several downstream tasks, demonstrating consistent improvements across various architectures without adding complexity during inference.
- Accuracy Gains: HAT consistently boosted performance. ViT-B improved from 82.0% to 83.2% top-1 accuracy, and Swin-B reached 84.0%. Notably, VOLO-D5 achieved a state-of-the-art 87.3% top-1 accuracy using only ImageNet-1K data.
- Robustness and OOD: The benefits of HAT extend to out-of-distribution (OOD) scenarios. The method provided a +4.6% boost on ImageNet-A for ViT-S and improved performance on ImageNet-C (corruptions) and ImageNet-Sketch.
- Downstream Tasks: Pre-training with HAT also benefited object detection and segmentation. A Swin-T backbone pre-trained with HAT showed a 0.4% AP improvement on the COCO dataset compared to standard pre-training.
Insights into Model Behavior
The paper offers several key takeaways regarding the nature of ViT training and the role of frequency analysis:
- Attention as a Smoother: Empirical evidence confirms that self-attention layers inherently diminish high-frequency information as the network depth increases.
- Augmentation Synergy: Analysis of standard augmentations shows that RandAugment helps capture high-frequency info, while CutMix primarily aids global context. HAT complements these by specifically targeting the high-frequency gap.
- Cross-Architectural Distillation: When performing Knowledge Distillation (KD), using a CNN as a teacher is more effective for a ViT student than using another ViT. The CNN teacher effectively helps the student bridge the high-frequency gap.
Conclusion and Limitations
HAT represents a novel intersection between adversarial robustness and architectural optimization. By identifying and addressing the low-pass filtering nature of self-attention, the authors provide a path toward more capable Vision Transformers.
The primary drawback of HAT is increased training time; the method requires multiple forward and backward passes to generate perturbations, making the training cost roughly 1.7x to 2.3x higher than standard training. Future work may focus on architectural changes that inherently preserve high-frequency information without the need for expensive adversarial loops.
Summary updated