DilateFormer: Multi-Scale Dilated Transformer for Visual Recognition

Jiayu Jiao, Yu-Ming Tang, Kun-Yu Lin, Yipeng Gao, Andy J. Ma, Yaowei Wang, Wei-Shi ZhengIEEE Trans. Multimedia 2023 · DOI

Introduction

Vision Transformers (ViTs) have fundamentally shifted the landscape of computer vision, offering superior performance across a variety of tasks. However, they face a persistent challenge: the trade-off between the receptive field size and computational efficiency. While global self-attention provides a comprehensive view of an image, its quadratic complexity makes it prohibitively expensive for high-resolution inputs. Conversely, local attention mechanisms, such as those used in the Swin Transformer, reduce costs but often at the expense of a restricted receptive field.

DilateFormer addresses this "Goldilocks problem" by introducing Multi-Scale Dilated Attention (MSDA). This approach is rooted in the empirical observation that attention patterns in the early layers of standard ViTs are naturally local and sparse. By mimicking these patterns, DilateFormer achieves state-of-the-art performance while significantly reducing the computational footprint.

The Locality and Sparsity Observation

The design of DilateFormer is motivated by an analysis of how standard ViTs process information. In the shallow stages of these models, the attention maps reveal that most patches primarily interact with their immediate neighbors, and even within those neighborhoods, the importance of patches is sparse. This suggests that global attention is redundant in early layers. DilateFormer exploits this by replacing dense global attention with a sparse, dilated alternative that maintains a large receptive field without the associated cost.

Multi-Scale Dilated Attention (MSDA)

The core innovation of the DilateFormer architecture is the MSDA block, which consists of several key components:

  • Sliding Window Dilated Attention (SWDA): Rather than attending to every patch within a local window, SWDA employs a dilation rate to skip certain patches. This allows the model to cover a much larger spatial area (e.g., a 7x7 area) while only processing a fraction of the patches (equivalent to a 3x3 area).
  • Multi-Scale Strategy: To capture a diverse range of features, MSDA assigns different dilation rates to different attention heads within a single block. For instance, one head might focus on immediate local context (dilation=1), while another captures broader structural information (dilation=3). This allows the model to aggregate multi-scale information simultaneously.
  • Hybrid Pyramid Architecture: DilateFormer utilizes a multi-stage pyramid structure. In the shallow stages, where image resolution is high and attention is naturally sparse, the model uses MSDA to maintain efficiency. In the deep stages, where the feature maps have been downsampled and the computational cost is lower, the model switches to standard Global Multi-Head Self-Attention (MHSA) to capture final global dependencies.

Experimental Results

DilateFormer was rigorously tested against standard benchmarks, demonstrating significant efficiency gains and performance improvements over existing models.

ImageNet-1K Classification

On the ImageNet-1K benchmark, Dilate-S achieved a 83.3% top-1 accuracy. Most notably, it matched the performance of the much larger Swin-B model while utilizing 70% fewer FLOPs (floating-point operations). The larger DilateFormer-Base model reached 85.6% top-1 accuracy when fine-tuned at a 384x384 resolution.

Downstream Tasks: Detection and Segmentation

The benefits of the multi-scale approach are particularly evident in dense prediction tasks:

  • Object Detection (COCO): Dilate-B achieved 53.5% box mAP, outperforming specialized models like Focal-B and Swin-B.
  • Semantic Segmentation (ADE20K): The model reached 51.1% MS mIoU, setting a new efficiency benchmark for understanding complex scenes at the pixel level.

Conclusion and Future Directions

DilateFormer demonstrates that by aligning attention mechanisms with the natural sparsity of visual data, it is possible to build models that are both powerful and efficient. While the model sets a new standard for performance-to-computation ratios, the authors note that the implementation of sliding window operations can be further optimized for specific hardware. Future research may also explore how these dilated attention strategies scale to "Huge" or "Giant" models containing billions of parameters, potentially unlocking even greater capabilities for large-scale visual recognition.

Summary updated

BibTeX
@misc{jiao2023dilateformer,
  author = {Jiayu Jiao and Yu-Ming Tang and Kun-Yu Lin and Yipeng Gao and Andy J. Ma and Yaowei Wang and Wei-Shi Zheng},
  title = {{DilateFormer: Multi-Scale Dilated Transformer for Visual Recognition}},
  year = {2023},
  eprint = {2302.01791},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2302.01791},
}
Figure