All models

swin_v2_t

Swin Transformer reworked with post-norm, cosine attention and log-spaced bias to scale up.

Image classification · 899 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (29 KB)

Open in a new tab

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.

At a glance

Family
Swin V2
Parameters
28.4M
Operations
899
Framework
PyTorch
Recurrent
No
Published
CVPR (arXiv 2021)
Cited by
2,415 (as of 9 October 2026)
Authors
Ze Liu, Han Hu, Yutong Lin and others
License
BSD-3-Clause
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m10429
Graph hash
5fa4b112306324143f54dd5c15906ec59fbfdaabbc801444ac787a008046e824
Skeleton hash
b91696db741499f6a0ce4b84b0a53a7b8a8b0d4ed507e85d2530e7d80c936117
Architecture hash
928d6c8b96069bb9e1ae141b97340946372f72d5d93b44c5a7cba686f205e1a4
Diagram SHA-256
97d264bdb80a8b94f862ba90e3794bf71532ae8642d3d7bc2f9532301cf3cb6e
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

SwinV2-T uses C = 96 first-stage channels with blocks {2, 2, 6, 2}.

About this model's family

Swin Transformer V2 is the adapted version of the original Swin Transformer, reworked so that both model capacity and window resolution can be scaled up. The underlying Swin idea is to bring visual priors such as hierarchy, locality and translation invariance into a vanilla Transformer encoder, so the block keeps its modeling power while suiting many visual tasks. The motivation is that scaling up language models had been incredibly successful. The scaling up of vision models, by contrast, had been lagging behind.

The first two changes target training stability: a residual-post-norm method combined with cosine attention. Post-norm normalizes the output of each residual block before it merges back into the main branch, so the amplitude of the main branch does not accumulate as the network gets deeper. Scaled cosine attention makes the computation independent of the amplitude of block inputs, so attention values are less likely to fall into extremes. The third change, a log-spaced continuous position bias (Log-CPB), generates bias values for arbitrary coordinate ranges by applying a small meta network to log-spaced coordinates, so a model pre-trained at low resolution can move to larger windows. Alongside the architecture, the paper uses the self-supervised SimMIM method to reduce its need for vast labeled images.

With these techniques the authors trained a 3 billion-parameter Swin Transformer V2 model. It set new performance records on ImageNet-V2 image classification, COCO object detection, ADE20K semantic segmentation and Kinetics-400 video action classification. The members traced here are torchvision's swin_v2_t, swin_v2_s and swin_v2_b builders, which all rely on the same SwinTransformer base class. The paper keeps the stage, block and channel settings of the original Swin Transformer for its four standard configurations. SwinV2-T uses C = 96 first-stage channels with blocks {2, 2, 6, 2}. SwinV2-S and SwinV2-B use 96 and 128 channels with blocks {2, 2, 18, 2}. Without fine-tuning, enlarging the window from 8 to 24 leaves accuracy at 78.9% versus 81.8%, where the original approach degrades from 81.7% to 68.7%.

Key idea. Swin Transformer V2 adds res-post-norm and scaled cosine attention to make the model easier to scale up in capacity, plus a log-spaced continuous relative position bias so it transfers more effectively across window resolutions.

  • swin transformer v2
  • swin v2
  • swinv2
  • swin_v2_t
  • swin_v2_s
  • swin_v2_b
  • hierarchical vision transformer
  • image classification
  • backbone
  • torchvision

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{liu2022swintransformerv2scaling,
      title={Swin Transformer V2: Scaling Up Capacity and Resolution}, 
      author={Ze Liu and Han Hu and Yutong Lin and Zhuliang Yao and Zhenda Xie and Yixuan Wei and Jia Ning and Yue Cao and Zheng Zhang and Li Dong and Furu Wei and Baining Guo},
      year={2022},
      eprint={2111.09883},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2111.09883}, 
}