All models

swin_s3_base_224

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

Image classification · 1,842 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 (19 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
71.1M
Operations
1,842
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
m10419
Graph hash
4fdd9f7a5a9fa99328e2d84e689be0ed336bde71f38a4e99bb1a5e7fddadf3e9
Skeleton hash
d8652af46d6b468dd583cec65a1291ff45509666ac65d536ccf537af74beaa14
Architecture hash
77f5661705dd3885a04d72ae02405018799c7aab3683ceabb7b8609e4fd937f5
Diagram SHA-256
989ce4bcb3c37239af0e32305d13a89a204961552c2adf2fcaf31196c978c6f6
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_s3_base_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}, 
}