{"notes":[{"id":"vision-transformers/swin-transformer","category":"vision-transformers","legacyPath":"vision-transformers/2103-swin-transformer","legacySlug":"2103-swin-transformer","legacyPaths":[],"title":"Swin Transformer","subtitle":"The Dance Begins","author":"Z. Yuan","paperDate":"2021-03-25","publishedOn":"2024-08-04","paperTitle":"Swin Transformer: Hierarchical Vision Transformer using Shifted Windows","paperUrl":"https://arxiv.org/abs/2103.14030","bibliography":{"title":"Swin Transformer: Hierarchical Vision Transformer using Shifted Windows","authors":["Ze Liu","Yutong Lin","Yue Cao","Han Hu","Yixuan Wei","Zheng Zhang","Stephen Lin","Baining Guo"],"url":"https://arxiv.org/abs/2103.14030","pdfUrl":"https://arxiv.org/pdf/2103.14030","codeUrl":null,"preprint":{"id":"2103.14030","submittedOn":"2021-03-25","url":"https://arxiv.org/abs/2103.14030"},"publication":{"venue":"ICCV","year":2021,"kind":"conference","url":"https://openaccess.thecvf.com/content/ICCV2021/html/Liu_Swin_Transformer_Hierarchical_Vision_Transformer_Using_Shifted_Windows_ICCV_2021_paper.html"},"citation":"@misc{visiontransformersswintransformer2021,\n  title = {{Swin Transformer: Hierarchical Vision Transformer using Shifted Windows}},\n  author = {Ze Liu and Yutong Lin and Yue Cao and Han Hu and Yixuan Wei and Zheng Zhang and Stephen Lin and Baining Guo},\n  year = {2021},\n  eprint = {2103.14030},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2103.14030}\n}\n","citationPath":"/content/papers/citations/vision-transformers/swin-transformer.f6a161083008.bib"},"thumbnail":{"src":"/content/papers/assets/8b4ce387b40cac8be3a6a99545bbe6a5e87126f19c80c24a7de318e32d5f626b.jpg","width":1596,"height":468},"locale":"en","path":"/content/papers/en/vision-transformers/swin-transformer.89422680b5fc.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"multi-scale-detection-capability","text":"Multi-scale Detection Capability","depth":3},{"id":"quadratic-complexity","text":"Quadratic Complexity","depth":3},{"id":"solutions","text":"Solutions","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"sliding-windows","text":"Sliding Windows","depth":3},{"id":"new-challenges","text":"New Challenges","depth":3},{"id":"cyclic-shift","text":"Cyclic Shift","depth":3},{"id":"special-masking","text":"Special Masking","depth":3},{"id":"reverse-shift","text":"Reverse Shift","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"performance-on-imagenet-1k","text":"Performance on ImageNet-1K","depth":3},{"id":"object-detection-settings","text":"Object Detection Settings","depth":3},{"id":"swin-vs-resnext","text":"Swin vs ResNe(X)t","depth":3},{"id":"swin-vs-deit","text":"Swin vs DeiT","depth":3},{"id":"swin-vs-sota","text":"Swin vs SOTA","depth":3},{"id":"ablation-studies","text":"Ablation Studies","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"vision-transformers/pvt","relation":"comparison","topic":"Multiscale visual Transformers"},{"id":"vision-transformers/vit","relation":"comparison","topic":"Multiscale visual Transformers"}]},{"id":"vision-transformers/pvt","category":"vision-transformers","legacyPath":"vision-transformers/2102-pvt","legacySlug":"2102-pvt","legacyPaths":[],"title":"PVT","subtitle":"Spatial Reduction Attention Mechanism","author":"Z. Yuan","paperDate":"2021-02-24","publishedOn":"2024-07-03","paperTitle":"Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions","paperUrl":"https://arxiv.org/abs/2102.12122","bibliography":{"title":"Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions","authors":["Wenhai Wang","Enze Xie","Xiang Li","Deng-Ping Fan","Kaitao Song","Ding Liang","Tong Lu","Ping Luo","Ling Shao"],"url":"https://arxiv.org/abs/2102.12122","pdfUrl":"https://arxiv.org/pdf/2102.12122","codeUrl":null,"preprint":{"id":"2102.12122","submittedOn":"2021-02-24","url":"https://arxiv.org/abs/2102.12122"},"publication":{"venue":"ICCV","year":2021,"kind":"conference","url":"https://arxiv.org/abs/2102.12122"},"citation":"@misc{visiontransformerspvt2021,\n  title = {{Pyramid Vision Transformer: A Versatile Backbone for Dense Prediction without Convolutions}},\n  author = {Wenhai Wang and Enze Xie and Xiang Li and Deng-Ping Fan and Kaitao Song and Ding Liang and Tong Lu and Ping Luo and Ling Shao},\n  year = {2021},\n  eprint = {2102.12122},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2102.12122}\n}\n","citationPath":"/content/papers/citations/vision-transformers/pvt.c8c991637878.bib"},"thumbnail":{"src":"/content/papers/assets/0784052802290bf5595ec58a783a2cd29da20872dafa1be2fdf9d3ebd6813fbb.jpg","width":1368,"height":676},"locale":"en","path":"/content/papers/en/vision-transformers/pvt.f8ce86e06615.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"hierarchical-structure","text":"Hierarchical Structure","depth":3},{"id":"spatial-reduction-attention-sra","text":"Spatial Reduction Attention (SRA)","depth":3},{"id":"model-configuration","text":"Model Configuration","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"imagenet-performance","text":"ImageNet Performance","depth":3},{"id":"object-detection-performance","text":"Object Detection Performance","depth":3},{"id":"contribution-of-the-pyramid-structure","text":"Contribution of the Pyramid Structure","depth":3},{"id":"depth-vs-width-trade-off","text":"Depth vs. Width Trade-off","depth":3},{"id":"addressing-but-not-solving-the-core-issue","text":"Addressing but Not Solving the Core Issue","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"vision-transformers/swin-transformer","relation":"comparison","topic":"Multiscale visual Transformers"},{"id":"vision-transformers/vit","relation":"comparison","topic":"Multiscale visual Transformers"}]},{"id":"vision-transformers/vit","category":"vision-transformers","legacyPath":"vision-transformers/2010-vit","legacySlug":"2010-vit","legacyPaths":[],"title":"ViT","subtitle":"Pioneering a New World","author":"Z. Yuan","paperDate":"2020-10-22","publishedOn":"2024-07-01","paperTitle":"An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale","paperUrl":"https://arxiv.org/abs/2010.11929","bibliography":{"title":"An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale","authors":["Alexey Dosovitskiy","Lucas Beyer","Alexander Kolesnikov","Dirk Weissenborn","Xiaohua Zhai","Thomas Unterthiner","Mostafa Dehghani","Matthias Minderer","Georg Heigold","Sylvain Gelly","Jakob Uszkoreit","Neil Houlsby"],"url":"https://arxiv.org/abs/2010.11929","pdfUrl":"https://arxiv.org/pdf/2010.11929","codeUrl":null,"preprint":{"id":"2010.11929","submittedOn":"2020-10-22","url":"https://arxiv.org/abs/2010.11929"},"publication":{"venue":"ICLR","year":2021,"kind":"conference","url":"https://openreview.net/pdf?id=YicbFdNTTy"},"citation":"@misc{visiontransformersvit2020,\n  title = {{An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale}},\n  author = {Alexey Dosovitskiy and Lucas Beyer and Alexander Kolesnikov and Dirk Weissenborn and Xiaohua Zhai and Thomas Unterthiner and Mostafa Dehghani and Matthias Minderer and Georg Heigold and Sylvain Gelly and Jakob Uszkoreit and Neil Houlsby},\n  year = {2020},\n  eprint = {2010.11929},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2010.11929}\n}\n","citationPath":"/content/papers/citations/vision-transformers/vit.8a478b78ec38.bib"},"thumbnail":{"src":"/content/papers/assets/82fb5d2f7ce623daf8d9ce146f096d22f2fb17d2532c5c4d613206f0424904aa.jpg","width":1472,"height":772},"locale":"en","path":"/content/papers/en/vision-transformers/vit.ae37d64b0944.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"solution","text":"Solution","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"patchify","text":"Patchify","depth":3},{"id":"and-then","text":"And Then?","depth":3},{"id":"lack-of-inductive-bias","text":"Lack of Inductive Bias","depth":3},{"id":"training-data-must-be-large","text":"Training Data Must Be Large","depth":3},{"id":"can-be-even-larger","text":"Can Be Even Larger","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"what-does-vit-see","text":"What Does ViT See?","depth":3},{"id":"predict-with-cls-or-gap","text":"Predict with [CLS] or GAP?","depth":3},{"id":"self-supervised-training","text":"Self-Supervised Training","depth":3},{"id":"other-considerations","text":"Other Considerations","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"vision-transformers/deit","relation":"next","topic":"Learning visual representations with Transformers"},{"id":"vision-transformers/pvt","relation":"comparison","topic":"Multiscale visual Transformers"},{"id":"vision-transformers/swin-transformer","relation":"comparison","topic":"Multiscale visual Transformers"}]}],"text":"At the same time, the PVT was proposed, which also incorporated the hierarchical structure of convolutional networks into the Transformer.\n\n- [**[21.02] PVT: Spatial Reduction Attention Mechanism**](/blog/papers/vision-transformers/pvt)\n\nPVT uses the SRA mechanism (Spatial Reduction Attention) to reduce the computational cost of the attention mechanism, but this approach doesn't truly solve the problem, as the quadratic complexity of the attention mechanism still exists.\n\n## Problem Definition\n\n![problem](/content/papers/assets/3126aa28ca068e4f49e0773ac76740249c85e7b7ac4d43d9a5087503973fd5cc.jpg)\n\nIn this paper, the authors target the original ViT architecture, identifying several key issues:\n\n### Multi-scale Detection Capability\n\nOriginal ViT outputs a single feature scale, commonly from 16×16-pixel patches. It can be adapted for detection and segmentation, but multiscale heads require additional feature-resolution handling and the attention cost can be high.\n\n### Quadratic Complexity\n\nFor object detection, the input size isn't limited to 224 x 224 images.\n\nLarger input images significantly increase the computational cost of the attention mechanism. For instance, a 224 x 224 image produces 14 x 14 = 196 patches; for a 1536 x 1536 image, the patch count increases to 96 x 96 = 9216. Performing self-attention on this many patches is computationally prohibitive, limiting ViT's application to large images.\n\n## Solutions\n\n### Model Architecture\n\n![model arch](/content/papers/assets/8b4ce387b40cac8be3a6a99545bbe6a5e87126f19c80c24a7de318e32d5f626b.jpg)\n\nTo handle the multi-scale problem, a hierarchical architecture is adopted, as shown in the Swin-T architecture above.\n\nAn input image of H x W x 3 is split into patches of size 4 x 4, and the feature dimension is projected to C dimensions, resulting in a feature map of size H/4 x W/4 x C. The 48 in the figure represents a patch containing 4 x 4 x 3 pixels, which is then transformed to C dimensions, where C is 96.\n\n\n> [!TIP]\n> \n> In practice, this step is often implemented using a convolution operation for simplicity, though the authors illustrate it in more detail here for clarity.\n\n\nBlocks alternate regular window attention (W-MSA) and shifted window attention (SW-MSA) in pairs, so each stage shown has an even number of blocks. Both are Swin blocks; this is not an alternation of global-attention ViT blocks with Swin blocks.\n\nPatch merging concatenates each group of 2×2 neighboring tokens along channels; it does not split one patch into four. The intermediate shape changes from H×W×C to H/2×W/2×4C.\n\nHere’s an illustrative diagram:\n\n\n\n![patch merging](/content/papers/assets/da9f4b6e902a42138f6b6e0d0705c93035f4342046a73d177b9180036b1c5e9f.jpg)\n\n\n\nSwin V1 applies LayerNorm after concatenation, then a linear projection from 4C to 2C. The projection is equivalent to a 1×1 convolution, but that description must not omit LayerNorm.\n\nNow that we’ve understood the basic architecture, let’s examine the details of the Swin blocks.\n\n### Sliding Windows\n\n![sliding window](/content/papers/assets/e84f6ed4d74856327be691632cf5206922369373e94c010824c3e8349a7b3c40.jpg)\n\nAccording to the paper:\n\n- Gray squares represent tokens. In the first stage each covers 4×4 input pixels; deeper stages merge tokens and cover larger regions.\n- The default window has M×M tokens with M=7. The conceptual figure instead uses M=4 for clarity.\n\nWith fixed M=7, each window contains 49 tokens. For N total tokens, all attention matrices contain about 49N elements rather than N². The fuller cost is $4NC^2+2M^2NC$: linear in N for fixed M and C, not linear in image side length.\n\n**But this design prevents information flow between windows, hindering the full potential of the Transformer.**\n\nSuccessive layers shift the partition by $\\lfloor M/2\\rfloor$ tokens per axis: two for the M=4 illustration, three for the default M=7. New windows cross the previous boundaries and connect neighboring regions.\n\n\n> [!TIP]\n> \n> To help understand this, we created a rough explanatory diagram to show how the paper’s figure transitions from left to right:\n> \n> ![shifted window](/content/papers/assets/e84668cef59ec8a128828151e005399043c1886d2fb12e77314701bc66e32024.jpg)\n\n\n### New Challenges\n\nThis method introduces a new challenge:\n\nIf the partition boundaries are shifted directly, an $N \\times N$ grid may become $(N+1) \\times (N+1)$ windows of different sizes. The paper’s 2×2 example becomes 3×3; padding each partial window to a fixed size would add attention work.\n\nThis is unacceptable for the authors.\n\nTo solve this, they propose a special masking method.\n\n### Cyclic Shift\n\n![mask](/content/papers/assets/920d51021781485594c283d75b9dd608d46dba2094eb3c3ef56d50b0108dbf59.jpg)\n\nImplementation first cyclically shifts the entire feature map toward the top-left, then partitions fixed-size windows. Tokens wrapped from opposite edges must be masked so that originally distant regions do not become artificial neighbors.\n\n\n> [!TIP]\n> \n> We understand the confusion here. To clarify, let’s number the nine windows A to I:\n> \n> The hand sketches move regions right and down by three to illustrate how they wrap around. In the actual computation, the feature map rolls left/up before window partitioning, then rolls right/down afterward. The windows and mask in the paper’s figure determine the actual attention pattern.\n> \n> First, consider moving the regions right by three:\n> \n> \n> \n> ![cycle shift](/content/papers/assets/52199872511e3ffca18d3c77be611f9aac26614dad9ec379208247cba0b4d748.jpg)\n> \n> \n> \n> Then move them down by three:\n> \n> \n> \n> ![cycle shift](/content/papers/assets/067d615ebc82577890fb57309df7f2d8eaeece1ed20404ee372c3f47777ebf0f.jpg)\n> \n> \n> \n> Together, these steps help us understand the cyclic rearrangement in the paper’s figure:\n> \n> \n> \n> ![cycle shift](/content/papers/assets/5032be5a964579340561cf959b3709e839ea5fecb2fdb330c27d692c393671ab.jpg)\n> \n> \n\n\nThis way, we retain the same number of fixed-size windows as regular partitioning instead of padding extra partial windows.\n\nThe mask blocks only artificial connections caused by wraparound. Tokens in a genuine shifted window can still interact across old window boundaries; masking all old cross-window connections would defeat the design.\n\n### Special Masking\n\n\n> [!TIP]\n> \n> Though this section leans more towards engineering implementation, it’s particularly brilliant!\n\n\nThis part is complex, so we refer to the author's explanation on GitHub:\n\n- [**Swin-Transformer/issues/38**](https://github.com/microsoft/Swin-Transformer/issues/38)\n\n![mask](/content/papers/assets/3ff2e763989dbe7854e1ad246c7b88f43cd826c023a2f61fcb2c74592cefcd26.png)\n\nLet’s break down this mask design, as patches in each window need to be aligned for corresponding operations:\n\n1. The first window is complete, so no attention mask is needed.\n2. Window 1 contains regions 1 and 2 from the Image Mask at left; these regions were not adjacent before the cyclic shift.\n\n\n> [!TIP]\n> \n> The two regions sit side by side in each row. They recur after flattening, producing the grid-like mask in the upper-right panel.\n\n\n3. Window 2 contains regions 3 and 6, which were not adjacent before the cyclic shift.\n\n\n> [!TIP]\n> \n> The two regions occupy the upper and lower parts of the window. Tokens from each region remain together after flattening, producing the large mask block in the lower-left panel.\n\n\n4. Window 3 contains regions 4, 5, 7, and 8.\n\n\n> [!TIP]\n> \n> This combines the two arrangements, so the lower-right attention mask contains both a grid-like pattern and large blocks.\n\n\n### Reverse Shift\n\nAfter cyclic shift and special masking, the authors effectively enable information flow between windows while maintaining linear complexity. Finally, a reverse shift restores the original window positions, providing a complete feature map.\n\nReverse shifting aligns the attention output with the original coordinates for the residual branch and subsequent spatial operations.\n\n## Discussion\n\n### Performance on ImageNet-1K\n\n![imagenet](/content/papers/assets/f6c49b8687231cdbd494f93dc2446a01fc2226e33eeaf2653032508324d915fb.jpg)\n\nFor image classification, the authors benchmarked the proposed Swin Transformer on ImageNet-1K.\n\nThis dataset contains 1.28 million training images and 50,000 validation images across 1,000 classes. The training setup includes:\n\n- **Optimizer**: AdamW\n- **Training Epochs**: 300\n- **Learning Rate Scheduler**: Cosine decay\n- **Linear Warmup**: 20 epochs\n- **Batch Size**: 1024\n- **Initial Learning Rate**: 0.001\n- **Weight Decay**: 0.05\n- **Augmentation and Regularization**: Includes most strategies except repeated augmentation and EMA, as they did not improve this training setup.\n\n---\n\nThe table above compares different backbone networks, including Transformer and ConvNet-based ones trained on standard ImageNet-1K.\n\nCompared to previous state-of-the-art Transformer architectures (e.g., DeiT), Swin Transformers show significant performance improvements.\n\n- **Swin-T (81.3%)** outperforms **DeiT-S (79.8%)** by 1.5 percentage points, though its listed throughput is lower (755.2 versus 940.4 images/s).\n- **Swin-B (83.5%/84.5%)** outperforms **DeiT-B (81.8%/83.1%)** by 1.7 and 1.4 percentage points at 224/384 input, respectively.\n\nAgainst ConvNet architectures such as RegNet and EfficientNet, accuracy, input size, and throughput vary by configuration. For example, at 224 input Swin-B reaches 83.5% at 278.1 images/s, while RegNetY-16G reaches 82.9% at 334.7 images/s; the table does not show that every Swin configuration is faster. While RegNet and EfficientNet were obtained through architecture search, Swin Transformer is adapted from the standard Transformer and may improve further.\n\n### Object Detection Settings\n\nThe architecture mainly aims to solve multi-scale issues, making its performance on object detection tasks more significant.\n\nObject detection and instance segmentation experiments are conducted on the COCO 2017 dataset, which includes 118K training images, 5K validation images, and 20K test-dev images.\n\nFor ablation studies, the authors consider four typical object detection frameworks:\n\n1. Cascade Mask R-CNN\n2. ATSS\n3. RepPoints v2\n4. Sparse RCNN\n\nThese frameworks share the same training settings:\n\n- **Multi-scale training**: Adjust input size so the short side is between 480 to 800 while the long side is up to 1333.\n- **Optimizer**: AdamW (initial learning rate 0.0001, weight decay 0.05, batch size 16).\n- **Training Epochs**: 3x schedule (36 epochs).\n\nFor system-level comparison, the authors use an improved HTC (HTC++) with:\n\n- instaboost\n- Stronger multi-scale training\n- 6x schedule (72 epochs)\n- soft-NMS\n- Initialization of the Swin models with ImageNet-22K pretraining\n\nThey compare Swin Transformer with standard ConvNets (e.g., ResNe(X)t) and previous Transformer networks (e.g., DeiT), keeping the detection framework and training settings as consistent as possible. Swin Transformer and ResNe(X)t produce hierarchical feature maps suitable for these frameworks, but DeiT produces a single-resolution feature map, so the DeiT comparison also uses a deconvolution layer to construct hierarchical features.\n\n### Swin vs ResNe(X)t\n\n\n\n![result](/content/papers/assets/8dd185df0062391bb275de1707537e689f29136ab17f93d6c27637ecd2f3a2d6.jpg)\n\n\nTable (a) shows Swin-T and ResNet-50 results on four object detection frameworks.\n\n- Swin-T provides consistent +3.4∼4.2 box AP improvements over ResNet-50.\n- Model size, FLOPs, and latency are slightly larger.\n\nTable (b) compares Swin Transformer and ResNe(X)t with Cascade Mask RCNN at different model capacities.\n\n- With Cascade Mask R-CNN, Swin-B achieves 51.9 box AP and 45.0 mask AP, improving by +3.6 box AP and +3.3 mask AP over ResNeXt101-64x4d with similar model size, FLOPs, and latency.\n\nWith the improved HTC++ framework on mini-val, ResNeXt101-64x4d scores 52.3 box AP and 46.0 mask AP, while Swin-B scores 56.4 and 49.1, gains of 4.1 and 3.1 AP (see table (c)).\n\nIn inference speed, although ResNe(X)t uses highly optimized Cudnn functions while Swin Transformer uses less optimized PyTorch functions, kernel optimization is beyond this paper's scope, so it's not discussed.\n\n### Swin vs DeiT\n\nTable (b) shows DeiT-S performance with Cascade Mask R-CNN.\n\n- Swin-T outperforms DeiT-S by +2.5 box AP and +2.3 mask AP, with similar model size (86M vs. 80M) and significantly higher inference speed (15.3 FPS vs. 10.4 FPS).\n\nDeiT's slower inference speed is mainly due to its quadratic complexity concerning input image size.\n\n### Swin vs SOTA\n\nTable (c) compares the best results with previous state-of-the-art models.\n\n- With ImageNet-22K pretraining and multi-scale testing, the best Swin-L + HTC++ system reaches 58.7 box AP and 51.1 mask AP on COCO test-dev. These are 2.7 and 2.6 AP above the table’s Copy-Paste 56.0 box AP and DetectoRS 48.5 mask AP, respectively. This is a system-level comparison across methods, unlike the backbone ablation. “No external data” qualifies the compared Copy-Paste setting, not an absence of external pretraining for Swin.\n\nThrough these comparisons and experimental results, the authors conclude:\n\n- Swin Transformer significantly outperforms ResNe(X)t and DeiT in multiple object detection frameworks.\n- In the roughly matched model-size comparisons of table (b), Swin Transformer improves detection and instance segmentation accuracy; costs across different frameworks and system settings need separate comparisons.\n- Despite current inference speed limitations due to less optimized PyTorch functions, Swin Transformer demonstrates strong performance potential.\n\n### Ablation Studies\n\nFinally, the authors detail ablation studies on Swin Transformer for image classification and object detection tasks to verify the effectiveness of key design elements.\n\n1. **Shifted Windows**\n\n   ![ablation](/content/papers/assets/c3b9e5ad5bb86e6183d26eda061e4708e1c7b995f698f144450a63c464042b1b.jpg)\n\n   The authors first investigate the effect of shifted windows.\n\n   Experiments show that Swin-T with shifted windows outperforms fixed-window partitioning across all tasks:\n\n   - On ImageNet-1K, top-1 accuracy improves by 1.1 percentage points.\n   - On COCO, box AP improves by 2.8, and mask AP by 2.2.\n   - On ADE20K, mIoU improves by 2.8.\n\n   These results highlight shifted windows' ability to effectively establish connections between windows in early layers. Moreover, the latency overhead from shifted windows is minimal.\n\n2. **Relative Position Bias**\n\n   Next, the authors compare different positional embedding methods.\n   Results show that Swin-T with relative position bias significantly outperforms methods without positional encoding and absolute positional embedding:\n\n   - On ImageNet-1K, top-1 accuracy improves by 1.2 and 0.8 percentage points.\n   - On COCO, box AP improves by 1.3 and 1.5, mask AP by 1.1 and 1.3.\n   - On ADE20K, mIoU improves by 2.3 and 2.9.\n\n   This indicates that relative position bias is effective across image classification, object detection, and semantic segmentation tasks.\n\n3. **Different Self-Attention Methods**\n\n   ![attention1](/content/papers/assets/fc9ce8a1464eedc50e3c60a341a749cf7a761f022d48abb58b2e0d9919149501.jpg)\n\n   Finally, the authors compare practical speeds of different self-attention computation methods.\n\n   Compared with padding partial shifted windows directly, cyclic shift raises whole-model throughput from 670/371/236 to 755/437/278 FPS for Swin-T/S/B, about 13%/18%/18% faster. The table also tests both naive and optimized-kernel sliding windows; the speed comparison depends on the implementation.\n\n   ![attention2](/content/papers/assets/9b3d98492846a0cbed9c23abda8a275e524e288afedd1c96e1ba1034e02609f6.jpg)\n\n   The authors also compare shifted windows with Performer using a Swin-T backbone: whole-model throughput is 755 versus 638 FPS in table 5, and ImageNet-1K top-1 accuracy is 81.3% versus 79.0% in table 6, a 2.3-point difference. Sliding windows reach a similar 81.4% top-1 accuracy, but both implementations in table 5 are slower.\n\n## Conclusion\n\nSwin Transformer is an innovative vision transformer that generates hierarchical feature representations with linear computational complexity concerning input image size. It demonstrates state-of-the-art performance on COCO object detection and ADE20K semantic segmentation tasks, significantly outperforming previous best methods.\n\nFinally, the authors highlight the key role of shifted windows in Swin Transformer and anticipate its application in NLP, potentially becoming a general-purpose transformer model.\n\n\n> [!TIP]\n> \n> We read this paper about five times. Since we're not smart enough, we had to read it multiple times...\n> \n> This paper is very impressive, and we recommend reading the original paper thoroughly.\n","imageSizes":{"/content/papers/assets/3126aa28ca068e4f49e0773ac76740249c85e7b7ac4d43d9a5087503973fd5cc.jpg":{"width":1086,"height":612},"/content/papers/assets/8b4ce387b40cac8be3a6a99545bbe6a5e87126f19c80c24a7de318e32d5f626b.jpg":{"width":1596,"height":468},"/content/papers/assets/da9f4b6e902a42138f6b6e0d0705c93035f4342046a73d177b9180036b1c5e9f.jpg":{"width":702,"height":459},"/content/papers/assets/e84f6ed4d74856327be691632cf5206922369373e94c010824c3e8349a7b3c40.jpg":{"width":1220,"height":490},"/content/papers/assets/e84668cef59ec8a128828151e005399043c1886d2fb12e77314701bc66e32024.jpg":{"width":4202,"height":1462},"/content/papers/assets/920d51021781485594c283d75b9dd608d46dba2094eb3c3ef56d50b0108dbf59.jpg":{"width":1396,"height":410},"/content/papers/assets/52199872511e3ffca18d3c77be611f9aac26614dad9ec379208247cba0b4d748.jpg":{"width":3474,"height":3180},"/content/papers/assets/067d615ebc82577890fb57309df7f2d8eaeece1ed20404ee372c3f47777ebf0f.jpg":{"width":3474,"height":3180},"/content/papers/assets/5032be5a964579340561cf959b3709e839ea5fecb2fdb330c27d692c393671ab.jpg":{"width":5477,"height":2475},"/content/papers/assets/3ff2e763989dbe7854e1ad246c7b88f43cd826c023a2f61fcb2c74592cefcd26.png":{"width":1113,"height":583},"/content/papers/assets/f6c49b8687231cdbd494f93dc2446a01fc2226e33eeaf2653032508324d915fb.jpg":{"width":968,"height":880},"/content/papers/assets/8dd185df0062391bb275de1707537e689f29136ab17f93d6c27637ecd2f3a2d6.jpg":{"width":1054,"height":1612},"/content/papers/assets/c3b9e5ad5bb86e6183d26eda061e4708e1c7b995f698f144450a63c464042b1b.jpg":{"width":980,"height":450},"/content/papers/assets/fc9ce8a1464eedc50e3c60a341a749cf7a761f022d48abb58b2e0d9919149501.jpg":{"width":976,"height":360},"/content/papers/assets/9b3d98492846a0cbed9c23abda8a275e524e288afedd1c96e1ba1034e02609f6.jpg":{"width":1224,"height":284}}}
