N Neurarch Architectures Checks Docs Open the app

Architectures / Computer Vision

๐ŸชŸ Swin-Tiny

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

Layers
81
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

81 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
15patch_merging_2LinearoutFeatures=192, inFeatures=3843136 ร— 192
16s2b1_norm1LayerNormnormalizedShape=1923136 ร— 192
17s2b1_window_attnMulti-Head AttentionembedDim=192, numHeads=63136 ร— 192
18s2b1_res1Add3136 ร— 192
19s2b1_norm2LayerNormnormalizedShape=1923136 ร— 192
20s2b1_mlpFeed ForwardembedDim=192, ffDim=7683136 ร— 192
21s2b1_res2Add3136 ร— 192
22s2b2_norm1LayerNormnormalizedShape=1923136 ร— 192
23s2b2_shifted_window_attnMulti-Head AttentionembedDim=192, numHeads=63136 ร— 192
24s2b2_res1Add3136 ร— 192
25s2b2_norm2LayerNormnormalizedShape=1923136 ร— 192
26s2b2_mlpFeed ForwardembedDim=192, ffDim=7683136 ร— 192
27s2b2_res2Add3136 ร— 192
28patch_merging_3LinearoutFeatures=384, inFeatures=7683136 ร— 384
29s3b1_norm1LayerNormnormalizedShape=3843136 ร— 384
30s3b1_window_attnMulti-Head AttentionembedDim=384, numHeads=123136 ร— 384
31s3b1_res1Add3136 ร— 384
32s3b1_norm2LayerNormnormalizedShape=3843136 ร— 384
33s3b1_mlpFeed ForwardembedDim=384, ffDim=15363136 ร— 384
34s3b1_res2Add3136 ร— 384
35s3b2_norm1LayerNormnormalizedShape=3843136 ร— 384
36s3b2_shifted_window_attnMulti-Head AttentionembedDim=384, numHeads=123136 ร— 384
37s3b2_res1Add3136 ร— 384
38s3b2_norm2LayerNormnormalizedShape=3843136 ร— 384
39s3b2_mlpFeed ForwardembedDim=384, ffDim=15363136 ร— 384
40s3b2_res2Add3136 ร— 384
41s3b3_norm1LayerNormnormalizedShape=3843136 ร— 384
42s3b3_window_attnMulti-Head AttentionembedDim=384, numHeads=123136 ร— 384
43s3b3_res1Add3136 ร— 384
44s3b3_norm2LayerNormnormalizedShape=3843136 ร— 384
45s3b3_mlpFeed ForwardembedDim=384, ffDim=15363136 ร— 384
46s3b3_res2Add3136 ร— 384
47s3b4_norm1LayerNormnormalizedShape=3843136 ร— 384
48s3b4_shifted_window_attnMulti-Head AttentionembedDim=384, numHeads=123136 ร— 384
49s3b4_res1Add3136 ร— 384
50s3b4_norm2LayerNormnormalizedShape=3843136 ร— 384
51s3b4_mlpFeed ForwardembedDim=384, ffDim=15363136 ร— 384
52s3b4_res2Add3136 ร— 384
53s3b5_norm1LayerNormnormalizedShape=3843136 ร— 384
54s3b5_window_attnMulti-Head AttentionembedDim=384, numHeads=123136 ร— 384
55s3b5_res1Add3136 ร— 384
56s3b5_norm2LayerNormnormalizedShape=3843136 ร— 384
57s3b5_mlpFeed ForwardembedDim=384, ffDim=15363136 ร— 384
58s3b5_res2Add3136 ร— 384
59s3b6_norm1LayerNormnormalizedShape=3843136 ร— 384
60s3b6_shifted_window_attnMulti-Head AttentionembedDim=384, numHeads=123136 ร— 384
61s3b6_res1Add3136 ร— 384
62s3b6_norm2LayerNormnormalizedShape=3843136 ร— 384
63s3b6_mlpFeed ForwardembedDim=384, ffDim=15363136 ร— 384
64s3b6_res2Add3136 ร— 384
65patch_merging_4LinearoutFeatures=768, inFeatures=15363136 ร— 768
66s4b1_norm1LayerNormnormalizedShape=7683136 ร— 768
67s4b1_window_attnMulti-Head AttentionembedDim=768, numHeads=243136 ร— 768
68s4b1_res1Add3136 ร— 768
69s4b1_norm2LayerNormnormalizedShape=7683136 ร— 768
70s4b1_mlpFeed ForwardembedDim=768, ffDim=30723136 ร— 768
71s4b1_res2Add3136 ร— 768
72s4b2_norm1LayerNormnormalizedShape=7683136 ร— 768
73s4b2_shifted_window_attnMulti-Head AttentionembedDim=768, numHeads=243136 ร— 768
74s4b2_res1Add3136 ร— 768
75s4b2_norm2LayerNormnormalizedShape=7683136 ร— 768
76s4b2_mlpFeed ForwardembedDim=768, ffDim=30723136 ร— 768
77s4b2_res2Add3136 ร— 768
78final_normLayerNormnormalizedShape=7683136 ร— 768
79avgpoolGlobalAvgPool1D3136
80classifierLinearoutFeatures=1000, inFeatures=7681000
81class_logitsOutput1000

What the verifier says

The same 41 structural 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)
#
# WARNING: 1 layer(s) below are not yet supported by the PyTorch
# exporter and pass their input through UNCHANGED in forward():
#   - avgpool (globalAvgPool1d)

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)

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