
shvit_s1
Image classification391 ops6.3M params
A memory-efficient vision transformer with a 16x16 stem, three stages and single-head partial-channel attention.
Image classification · 539 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('shvit_s4', pretrained=False) About this model's family
SHViT, the Single-Head Vision Transformer, is an efficient vision transformer built around removing computational redundancy at all design levels in a memory-efficient manner. Where conventional efficient ViTs use 4 by 4 patch embeddings and a 4-stage structure, SHViT adopts a 16 by 16 patchify stem and a 3-stage design. The authors find that a larger-stride patchify stem reduces memory access costs and stays competitive by leveraging token representations with reduced spatial redundancy from the early stages.
At the micro level, Single-Head Self-Attention applies an attention layer with a single head on only a part of the input channels and leaves the remaining channels untouched. The partial ratio r defaults to 1/4.67. This removes the redundancy of the multi-head mechanism and reduces memory access cost by processing partial channels. A SHViT block has three parts: a depthwise convolution for local feature aggregation, the SHSA layer for modeling global contexts, and a feed-forward network. The first stage uses no SHSA layer at all, following the finding that early-stage attention can be substituted with convolutions.
Layer Normalization is used only for the SHSA layer, with Batch Normalization elsewhere so it can be merged into adjacent convolution or linear layers. Four variants, S1 to S4, differ in depth and width, and all four are captured here. SHViT-S4 reaches 79.4% top-1 on ImageNet at 14283 images per second on an Nvidia A100 GPU and 509 images per second on an Intel Xeon Gold 5218R CPU.
Key idea. SHViT-S4 is 3.3x, 8.1x and 2.4x faster than MobileViTv2 x1.0 on GPU, CPU and iPhone 12 while being 1.3% more accurate, by using single-head attention on partial channels and a 16 by 16 stem with three stages.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{yun2024shvitsingleheadvisiontransformer,
title={SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design},
author={Seokju Yun and Youngmin Ro},
year={2024},
eprint={2401.16456},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2401.16456},
}