All models

swin_tiny_patch4_window7_224

Swin Transformer: hierarchical vision transformer with self-attention in shifted local windows.

Image classification · 663 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 (31 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
Parameters
28.3M
Operations
663
Framework
PyTorch
Recurrent
No
Published
2021
Cited by
60 (as of 18 November 2026)
Authors
Minghao Chen, Kan Wu, Bolin Ni and others
License
Apache-2.0
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
m10425
Graph hash
c0232ee6ba6626242b4b65d14c06ce37c35fa55fc9500ef4cbaaef79969f76e2
Skeleton hash
83e95317247d514c0de3dc81edcbbed6df2b635d5e862c014b61ac683c95c5b0
Architecture hash
ee9344f759c1eef0079f6901e339d25d4149e8d86fc548711dc3dfdcb38292b1
Diagram SHA-256
56513995402463e3ab703c5e2eefa4be83359b2416587e38b694721c372db943
TorchLens version
2.35.3
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

timm.create_model('swin_tiny_patch4_window7_224', pretrained=False)

What it is

About this model's family

Swin Transformer is a hierarchical vision transformer that serves as a general-purpose backbone for computer vision. Moving the Transformer from language to vision runs into large variations in the scale of visual entities and the high resolution of pixels compared to words. Its answer is shifted windows: self-attention is limited to non-overlapping local windows for efficiency, while shifting the windows between layers allows cross-window connection. This gives linear computational complexity in image size and the flexibility to model at various scales.

The network first splits the image into non-overlapping 4x4 patches, so each token starts as a 48-dimensional vector of raw pixel values that a linear embedding projects to dimension C. Patch merging layers then concatenate each 2x2 group of neighboring patches and apply a linear layer to the 4C-dimensional result, building the hierarchy stage by stage. The shifted partition is computed by a cyclic shift that keeps the number of batched windows the same as regular window partitioning. The learnt relative position bias from pre-training can also initialize a model for fine-tuning at a different window size through bi-cubic interpolation.

Swin-B is sized like ViT-B/DeiT-B, and Swin-T, Swin-S and Swin-L are about 0.25x, 0.5x and 2x its model size and compute. The window size is set to M = 7 by default. Swin-T uses C = 96 with layer numbers {2, 2, 6, 2}, and Swin-S keeps C = 96 with {2, 2, 18, 2}. Swin-B raises C to 128 and Swin-L to 192, both with layer numbers {2, 2, 18, 2}.

The timm members use code and weights from Microsoft's Swin-Transformer repository. The three swin_s3 members instead load S3 (AutoFormerV2) Swin weights from Microsoft's Cream repository. S3 models come from neural architecture search that searches not only the architecture but also the search space, gradually evolving the search dimensions guided by an E-T Error computed with a weight-sharing supernet. In Transformers, Swin can pad inputs to any height and width divisible by 32 and can be used as a backbone. The paper reports 87.3 top-1 on ImageNet-1K, 58.7 box AP and 51.1 mask AP on COCO test-dev, and 53.5 mIoU on ADE20K val.

Key idea. Self-attention inside shifted local windows, giving a hierarchical vision transformer with linear complexity in image size that works as a general-purpose backbone.

  • swin transformer
  • swin
  • swin-t
  • swin-s
  • swin-b
  • swin-l
  • shifted windows
  • s3
  • autoformerv2
  • image classification
  • backbone
  • microsoft

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

Cite the paper

@misc{chen2021searchingsearchspacevision,
      title={Searching the Search Space of Vision Transformer}, 
      author={Minghao Chen and Kan Wu and Bolin Ni and Houwen Peng and Bei Liu and Jianlong Fu and Hongyang Chao and Haibin Ling},
      year={2021},
      eprint={2111.14725},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2111.14725}, 
}