N Neurarch Architectures Models Checks Data Docs Open the app

Architectures / Computer Vision

๐ŸชŸ Swin-Tiny

Hierarchical vision transformer โ€” shifted-window attention builds a feature pyramid for dense prediction (Liu 2021)

From Liu et al. (2021). Swin Transformer: Hierarchical Vision Transformer using Shifted Windows. ICCV 2021. This page is the graph, not the PDF: open it, edit it, verify it, export it.

Layers
85
Parameters
28.26M
Input
3 ร— 224 ร— 224
Output
1000
Verifier
1 advisory

Every number on this page is computed from the graph by the same functions the app runs, not written by hand.

Open Swin-Tiny on the canvas Free, no account needed

When to pick it

Pick when you need a ViT that produces multi-scale features (detection, segmentation) rather than a single-scale ViT. Windowed attention keeps compute linear in image size.

Structure

85 layers. Output shapes are propagated from the input shape, batch dimension excluded.

LayerTypeParametersOutput shape
1imageInputshape=[3, 224, 224]3 ร— 224 ร— 224
2patch_embed_4x4Patch EmbedembedDim=96, patchSize=43136 ร— 96
3s1b1_norm1LayerNormnormalizedShape=963136 ร— 96
4s1b1_window_attnMulti-Head AttentionembedDim=96, numHeads=33136 ร— 96
5s1b1_res1Add3136 ร— 96
6s1b1_norm2LayerNormnormalizedShape=963136 ร— 96
7s1b1_mlpFeed ForwardembedDim=96, ffDim=3843136 ร— 96
8s1b1_res2Add3136 ร— 96
9s1b2_norm1LayerNormnormalizedShape=963136 ร— 96
10s1b2_shifted_window_attnMulti-Head AttentionembedDim=96, numHeads=33136 ร— 96
11s1b2_res1Add3136 ร— 96
12s1b2_norm2LayerNormnormalizedShape=963136 ร— 96
13s1b2_mlpFeed ForwardembedDim=96, ffDim=3843136 ร— 96
14s1b2_res2Add3136 ร— 96
15merge_patches_n15Reshapeshape=[784, 384]784 ร— 384
16patch_merging_2LinearoutFeatures=192, inFeatures=384784 ร— 192
17s2b1_norm1LayerNormnormalizedShape=192784 ร— 192
18s2b1_window_attnMulti-Head AttentionembedDim=192, numHeads=6784 ร— 192
19s2b1_res1Add784 ร— 192
20s2b1_norm2LayerNormnormalizedShape=192784 ร— 192
21s2b1_mlpFeed ForwardembedDim=192, ffDim=768784 ร— 192
22s2b1_res2Add784 ร— 192
23s2b2_norm1LayerNormnormalizedShape=192784 ร— 192
24s2b2_shifted_window_attnMulti-Head AttentionembedDim=192, numHeads=6784 ร— 192
25s2b2_res1Add784 ร— 192
26s2b2_norm2LayerNormnormalizedShape=192784 ร— 192
27s2b2_mlpFeed ForwardembedDim=192, ffDim=768784 ร— 192
28s2b2_res2Add784 ร— 192
29merge_patches_n28Reshapeshape=[196, 768]196 ร— 768
30patch_merging_3LinearoutFeatures=384, inFeatures=768196 ร— 384
31s3b1_norm1LayerNormnormalizedShape=384196 ร— 384
32s3b1_window_attnMulti-Head AttentionembedDim=384, numHeads=12196 ร— 384
33s3b1_res1Add196 ร— 384
34s3b1_norm2LayerNormnormalizedShape=384196 ร— 384
35s3b1_mlpFeed ForwardembedDim=384, ffDim=1536196 ร— 384
36s3b1_res2Add196 ร— 384
37s3b2_norm1LayerNormnormalizedShape=384196 ร— 384
38s3b2_shifted_window_attnMulti-Head AttentionembedDim=384, numHeads=12196 ร— 384
39s3b2_res1Add196 ร— 384
40s3b2_norm2LayerNormnormalizedShape=384196 ร— 384
41s3b2_mlpFeed ForwardembedDim=384, ffDim=1536196 ร— 384
42s3b2_res2Add196 ร— 384
43s3b3_norm1LayerNormnormalizedShape=384196 ร— 384
44s3b3_window_attnMulti-Head AttentionembedDim=384, numHeads=12196 ร— 384
45s3b3_res1Add196 ร— 384
46s3b3_norm2LayerNormnormalizedShape=384196 ร— 384
47s3b3_mlpFeed ForwardembedDim=384, ffDim=1536196 ร— 384
48s3b3_res2Add196 ร— 384
49s3b4_norm1LayerNormnormalizedShape=384196 ร— 384
50s3b4_shifted_window_attnMulti-Head AttentionembedDim=384, numHeads=12196 ร— 384
51s3b4_res1Add196 ร— 384
52s3b4_norm2LayerNormnormalizedShape=384196 ร— 384
53s3b4_mlpFeed ForwardembedDim=384, ffDim=1536196 ร— 384
54s3b4_res2Add196 ร— 384
55s3b5_norm1LayerNormnormalizedShape=384196 ร— 384
56s3b5_window_attnMulti-Head AttentionembedDim=384, numHeads=12196 ร— 384
57s3b5_res1Add196 ร— 384
58s3b5_norm2LayerNormnormalizedShape=384196 ร— 384
59s3b5_mlpFeed ForwardembedDim=384, ffDim=1536196 ร— 384
60s3b5_res2Add196 ร— 384
61s3b6_norm1LayerNormnormalizedShape=384196 ร— 384
62s3b6_shifted_window_attnMulti-Head AttentionembedDim=384, numHeads=12196 ร— 384
63s3b6_res1Add196 ร— 384
64s3b6_norm2LayerNormnormalizedShape=384196 ร— 384
65s3b6_mlpFeed ForwardembedDim=384, ffDim=1536196 ร— 384
66s3b6_res2Add196 ร— 384
67merge_patches_n65Reshapeshape=[49, 1536]49 ร— 1536
68patch_merging_4LinearoutFeatures=768, inFeatures=153649 ร— 768
69s4b1_norm1LayerNormnormalizedShape=76849 ร— 768
70s4b1_window_attnMulti-Head AttentionembedDim=768, numHeads=2449 ร— 768
71s4b1_res1Add49 ร— 768
72s4b1_norm2LayerNormnormalizedShape=76849 ร— 768
73s4b1_mlpFeed ForwardembedDim=768, ffDim=307249 ร— 768
74s4b1_res2Add49 ร— 768
75s4b2_norm1LayerNormnormalizedShape=76849 ร— 768
76s4b2_shifted_window_attnMulti-Head AttentionembedDim=768, numHeads=2449 ร— 768
77s4b2_res1Add49 ร— 768
78s4b2_norm2LayerNormnormalizedShape=76849 ร— 768
79s4b2_mlpFeed ForwardembedDim=768, ffDim=307249 ร— 768
80s4b2_res2Add49 ร— 768
81final_normLayerNormnormalizedShape=76849 ร— 768
82to_channelsPermute768 ร— 49
83avgpoolGlobalAvgPool1D768
84classifierLinearoutFeatures=1000, inFeatures=7681000
85class_logitsOutput1000

What the verifier says

The same 43 single-graph checks that run on every edit in the app, on this graph.

warn12 attention layer(s) present but no positional encoding found. Attention is permutation-invariant, without position information the model cannot distinguish token order. Fix: Add a PositionalEncoding (sinusoidal) or RoPE layer before the first attention layer. (s1b1_window_attn)
attention-no-pe
infoAt 12 stacked attention layers, residual-branch outputs add up; unscaled init lets activation variance grow with depth. GPT-2/LLaMA-family models scale the residual projections by depth (N(0, 0.02 / โˆš(2L))). Fix: Scale residual output projections by depth: nn.init.normal_(w, std=0.02 / math.sqrt(2 * n_layers)) (s1b1_window_attn)
deep-attention-default-init

The PyTorch it exports

Generated from the graph above. First 46 lines; the app exports the whole file, plus the training loop, the data contract and a deploy bundle.

# Architecture designed with Neurarch: https://neurarch.com
# PyTorch: compatible with Python 3.8+ and torch>=1.12
# Colab: pip install torch torchvision  (usually pre-installed)

import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple

class SwinTransformerTiny(nn.Module):
    def __init__(self):
        super().__init__()

        self.patchEmbed_1 = nn.Conv2d(3, 96, kernel_size=4, stride=4)  # Patch embedding (ViT-style)
        self.layerNorm_1 = nn.LayerNorm(96)
        self.multiHeadAttention_1 = nn.MultiheadAttention(embed_dim=96, num_heads=3, batch_first=True)
        self.layerNorm_2 = nn.LayerNorm(96)
        self.feedForward_1 = nn.Sequential(
            nn.Linear(96, 384),
            nn.ReLU(),
            nn.Linear(384, 96)
        )
        self.layerNorm_3 = nn.LayerNorm(96)
        self.multiHeadAttention_2 = nn.MultiheadAttention(embed_dim=96, num_heads=3, batch_first=True)
        self.layerNorm_4 = nn.LayerNorm(96)
        self.feedForward_2 = nn.Sequential(
            nn.Linear(96, 384),
            nn.ReLU(),
            nn.Linear(384, 96)
        )
        self.linear_1 = nn.Linear(384, 192)
        self.layerNorm_5 = nn.LayerNorm(192)
        self.multiHeadAttention_3 = nn.MultiheadAttention(embed_dim=192, num_heads=6, batch_first=True)
        self.layerNorm_6 = nn.LayerNorm(192)
        self.feedForward_3 = nn.Sequential(
            nn.Linear(192, 768),
            nn.ReLU(),
            nn.Linear(768, 192)
        )
        self.layerNorm_7 = nn.LayerNorm(192)
        self.multiHeadAttention_4 = nn.MultiheadAttention(embed_dim=192, num_heads=6, batch_first=True)
        self.layerNorm_8 = nn.LayerNorm(192)
        self.feedForward_4 = nn.Sequential(
            nn.Linear(192, 768),
            nn.ReLU(),
            nn.Linear(768, 192)

For agents

This architecture is machine-readable end to end. An agent can list the set, fetch this graph, edit it, and have the edit verified before any GPU time is spent.

Also in Computer Vision

๐Ÿ–ผ๏ธ Simple CNN
Simple Convolutional Neural Network for image classification
9 layers ยท 804.6K
๐Ÿ”— ResNet Block
ResNet residual block with skip connections
9 layers ยท 74.0K
๐Ÿฉป U-Net
Encoder-decoder with skip connections โ€” Ronneberger et al
24 layers ยท 720.7K
๐Ÿ‘๏ธ ViT-B/16
Vision Transformer โ€” patch embedding stem + 1 encoder block
13 layers ยท 8.45M