
maxvit_pico_rw_256
Image classification1,128 ops7.5M params
A hybrid backbone whose block-plus-grid attention gives global context at every stage in linear time.
Image classification · 1,304 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('maxvit_rmlp_pico_rw_256', pretrained=False) This rmlp variant uses a relative position MLP.
About this model's family
MaxViT is a hierarchical vision backbone that gets attention to see the whole image at every stage, including the early high-resolution ones, without paying the quadratic cost of full self-attention. Its authors frame the problem plainly: the lack of scalability of self-attention with respect to image size had kept Transformers out of state-of-the-art vision backbones. Their answer is multi-axis attention, two sparse forms of attention, blocked local and dilated global, that together allow global-local spatial interactions on arbitrary input resolutions with only linear complexity.
Look for the repeating unit in the graph: an MBConv block with squeeze-and-excitation, then block attention, then grid attention, each attention followed by a feed-forward network. Block attention partitions the feature map into non-overlapping windows and attends within each, which is local mixing. Grid attention instead overlays a fixed uniform grid on the whole map and attends among the pixels that share a grid position, which amounts to dilated, global mixing of tokens. Both use a window and grid size of 7, following Swin, so the local and global halves cost the same. The authors point out that this is a drop-in replacement for Swin's attention with exactly the same parameters and FLOPs, but with no masking, padding or cyclic shifting. The depthwise convolution inside MBConv doubles as a conditional position encoding, so you will find no explicit positional embedding layer.
The body has a two-convolution stem and four stages, each at half the resolution and double the channels of the one before, and the model is scaled by changing blocks per stage and channel width. The attention head size is 32 everywhere. On ImageNet-1K without extra data MaxViT reaches 86.5% top-1, and 88.7% with ImageNet-21K pre-training. The paper also uses MaxViT blocks for object detection, image aesthetic assessment and unconditional image generation; the captured members here are the classifiers only.
A note on provenance: timm's MaxViT is a from-scratch PyTorch implementation, done 99% from the paper with last-minute adjustments from the public code release. Members whose names carry _tf follow the TensorFlow release at 224, 384 or 512 pixels; those with _rw are the timm author's own configurations, which run a bit faster and lighter than the paper's. The rmlp members use a relative position MLP. One member, maxvit_t, comes from torchvision instead.
Key idea. Multi-axis self-attention (Max-SA): a single block that runs windowed block attention for local interactions and then grid attention for sparse global interactions, both in linear complexity, so global context is available from the first stage onward. Repeating one MBConv plus Max-SA block across a conventional four-stage hierarchy gives the MaxViT backbone.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{tu2022maxvitmultiaxisvisiontransformer,
title={MaxViT: Multi-Axis Vision Transformer},
author={Zhengzhong Tu and Hossein Talebi and Han Zhang and Feng Yang and Peyman Milanfar and Alan Bovik and Yinxiao Li},
year={2022},
eprint={2204.01697},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2204.01697},
}