Vision transformer

Attention · pattern · Image → Embedding, Scores, Image

Cuts an image into patches, embeds each as a token, and runs a transformer encoder over them.

Also called ViT, Image transformer, Patch transformer

Figure 1. The Vision transformer as a schematic: the parts it is built from and how data flows between them. Select a part to read about it.

What it does

A vision transformer splits the image into a grid of square patches, for example 16 × 16 pixels, and maps each patch to a vector with one strided convolution. The patch vectors become a token sequence; a learned class token is prepended and position embeddings are added. From there it is a standard pre-norm transformer encoder, so every patch can attend to every other patch from the first layer on. The class token’s final vector feeds a classifier or an image embedding; dense prediction heads (depth, segmentation) instead reshape the patch tokens back into a grid.

Formula

z0 = [xcls ; x1 E ; … ; xP E] + Pposz′ = z + MHA(LN(z)), znext = z′ + MLP(LN(z′))y = W · LN(zL[0]) + b

Shapes and parameters

Shapes
Image [N, 3, 224, 224] → patch grid [N, 192, 14, 14] → tokens [N, 197, 192] (196 patches + class token) → output [N, K].
Parameters
Patch embedding 3 × 16² × D + D, positions 197 × D, then about 12D² per layer. A ViT-Tiny (D = 192, 12 layers) has about 5.7 million.
Used for
TinyCLIP’s image encoder, Depth Anything’s DINOv2 backbone, VitTrack, SlimSAM’s image encoder.

Figure 2. A real vision transformer in WeightSpace: Track a subject between frames, drawn from the file the app runs. Open a module to see the parts inside.

In WeightSpace

Catalog vision transformers are edited after the encoder: final LayerNorm biases of the TinyCLIP image embedding, the depth head’s output bias, or the tracker’s box-offset and score biases, within ±8.