Dilated Neighborhood Attention Transformer

Ali Hassani, Humphrey Shi
9/29/2022
127 citations
cs.CVcs.AIcs.LG
transformer-attention

Official code: SHI-Labs/Neighborhood-Attention-Transformer (1,186 stars, Python, MIT, PyTorch, last commit 2024-05-15). 1 more implementation below.

Abstract

Transformers are quickly becoming one of the most heavily applied deep learning architectures across modalities, domains, and tasks. In vision, on top of ongoing efforts into plain transformers, hierarchical transformers have also gained significant attention, thanks to their performance and easy integration into existing frameworks.

Show full abstract

These models typically employ localized attention mechanisms, such as the sliding-window Neighborhood Attention (NA) or Swin Transformer's Shifted Window Self Attention. While effective at reducing self attention's quadratic complexity, local attention weakens two of the most desirable properties of self attention: long range inter-dependency modeling, and global receptive field. In this paper, we introduce Dilated Neighborhood Attention (DiNA), a natural, flexible and efficient extension to NA that can capture more global context and expand receptive fields exponentially at no additional cost. NA's local attention and DiNA's sparse global attention complement each other, and therefore we introduce Dilated Neighborhood Attention Transformer (DiNAT), a new hierarchical vision transformer built upon both. DiNAT variants enjoy significant improvements over strong baselines such as NAT, Swin, and ConvNeXt. Our large model is faster and ahead of its Swin counterpart by 1.6% box AP in COCO object detection, 1.4% mask AP in COCO instance segmentation, and 1.4% mIoU in ADE20K semantic segmentation. Paired with new frameworks, our large variant is the new state of the art panoptic segmentation model on COCO (58.5 PQ) and ADE20K (49.4 PQ), and instance segmentation model on Cityscapes (45.1 AP) and ADE20K (35.4 AP) (no extra data). It also matches the state of the art specialized semantic segmentation models on ADE20K (58.1 mIoU), and ranks second on Cityscapes (84.5 mIoU) (no extra data).

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
SHI-Labs/Neighborhood-Attention-TransformerOfficial1,186PythonMIT2024-05-15
SHI-Labs/NATTENCommunity813C++MIT2026-04-14
PyTorchMIT

Neighborhood Attention Transformer, arxiv 2022 / CVPR 2023. Dilated Neighborhood Attention Transformer, arxiv 2022

1,18689Python, ShellApr 14, 20222 years agoMIT
neighborhood-attentionpytorch
SHI-Labs/NATTENCommunity100%
PyTorchMIT

Fast Multi-dimensional Sparse Attention

81371C++, PythonOct 8, 20227 months agoMIT
cudaneighborhood-attentionpytorchsparse-attention

Similar Papers

Cite this paper

@article{hassani2022dilated,
  title  = {Dilated Neighborhood Attention Transformer},
  author = {Ali Hassani and Humphrey Shi},
  year   = {2022},
  eprint = {2209.15001},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2209.15001}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2209.15001.svg)](https://codeofpaper.com/paper/2209.15001)

Discussion