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]) + bShapes 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.
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.