
davit (MMPretrain)
Image classification86 ops731.4K params
A vision transformer that alternates window attention over patches with attention over channels.
Image classification · 1,147 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
How this diagram was made
timm.create_model('davit_base', pretrained=False) About this model's family
DaViT, the Dual Attention Vision Transformer, is a vision backbone that captures global context while keeping computation efficient. Its trick is to run self-attention two ways: over spatial tokens, where the spatial dimension defines the token scope and channels are the features, and over channel tokens, where the channel dimension defines the token scope and the spatial dimension is the feature. Each channel token is an abstract representation of the entire image, so channel attention captures global interactions by taking all spatial positions into account. Spatial attention refines the local representations with fine-grained interactions across locations.
To keep the whole model linear in cost, tokens are grouped along the sequence direction for both kinds of attention: spatial window attention partitions the image into non-overlapping windows, and channel group attention divides the channels into groups. A dual attention block pairs one spatial window attention block with one channel group attention block, and the model alternates the two.
The network has four stages, each opened by a patch embedding layer implemented as a strided convolution, with dual attention blocks stacked inside each stage at fixed resolution. The captured timm members cover the tiny, small, base, large, huge and giant sizes; Tiny and Small both use base width C = 96 and differ in the third stage, with 3 or 9 blocks. Without extra data, DaViT-Tiny, DaViT-Small and DaViT-Base reach 82.8%, 84.2% and 84.6% top-1 on ImageNet-1K with 28.3M, 49.7M and 87.9M parameters. Scaled up with 1.5B weakly supervised image and text pairs, the giant model reaches 90.4% top-1 on ImageNet-1K.
Key idea. Channel group self-attention, which treats each channel as an image-level token, alternated with spatial window attention so a vision transformer gets global context at linear cost.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@article{davit2022,
title = {DaViT: Dual Attention Vision Transformers},
author = {Mingyu Ding and Bin Xiao and Noel Codella and Ping Luo and Jingdong Wang and Lu Yuan},
year = {2022},
journal = {Lecture notes in computer science},
eprint = {2204.03645}
}