All models

swin_large_patch4_window7_224

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

Image classification · 1,305 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 (16 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
196.5M
Operations
1,305
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
m10416
Graph hash
71bfdcd9479131a52323bb45ae349ae221398c14059fe57424e9b44dad49e775
Skeleton hash
48d9862f56bdbb1dc4a1f761d0c278c37a51d256d69286a0e935783daafa4b11
Architecture hash
7e83a225cb3d2dcf65a5910a0f13589fa7ab93e68a46c44e000024e1e6dfc651
Diagram SHA-256
2ec324c4515467622abfa244dd875636e590ad833fbe8ecba71d58f7dd3b867c
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_large_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}, 
}