A Vision Transformer (ViT) applies Transformer architecture to visual data. It suits flexible, sequence-based image tasks and image recognition, but requires significant computational resources. section 4.1 section 4.1.3
Instead of comparing every pixel with every other pixel, ViT divides an image into small patches, commonly 16 × 16 pixels. It flattens those patches, adds positional embeddings, and feeds the resulting sequence into a Transformer encoder. section 4.1.3
A ViT processes an image through three practical stages:
- Projects flattened image patches into vectors that form a linear input sequence. section 4.1.3
- Uses global self-attention to learn relationships among different image regions simultaneously. section 4.1.3
- Applies multi-head attention and normalization layers before assigning an output class such as Bird, Ball, or Car. section 4.1.3
- Scales attention cost quadratically with the number of input patches, making patch selection and compute capacity important considerations. section 4.1.3
Figure 4.6 Vision transformer (ViT) architecture [2]
Inspect the architecture diagram to connect patch projection, the Transformer encoder, attention layers, normalization, and output classes. section 4.1.3
Classifying an image
An image is divided into 16 × 16 regions. Each region becomes a vector with positional information, and the encoder learns relationships across the full sequence before selecting a class such as Bird, Ball, or Car. section 4.1.3






