Count patch tokens
Calculate tokens for 224x224 images using 16x16 patches. Explain whether your count includes a class token.
Full name: Vision Transformer
Memory aid: Vision is processed by a Transformer.
Patch construction, pretraining, and evaluation affect visual performance.
Study area: AI & machine learning · Batch 9
Relevant study for: Azure AI Fundamentals AI-901 · Azure AI Apps and Agents Developer AI-103 · Azure AI Fundamentals (retired) AI-900 · Azure AI Engineer (retired) AI-102
Practice with exam flashcards →Data / Knowledge library
image patches processed with transformer attention
ViT embeds image patches as tokens, adds positional information, and processes them with Transformer blocks. Self-attention relates patches across the image. CNNs provide a useful comparison because their local filters encode different architectural assumptions. Neither approach is universally superior: compare accuracy, pretraining data, compute, and latency on the same task.
Provides an attention-based way to learn image representations. Standard global self-attention models relationships between all patch tokens; its pairwise attention computation grows quadratically with sequence length. Smaller patches or larger images increase the token count.
Dosovitskiy and colleagues introduced ViT in an October 2020 preprint, subsequently published at ICLR 2021. The work applied a Transformer to sequences of image patches and demonstrated strong image-recognition results after large-scale pretraining. ViT is an architecture family, not a product with one current release.
Work through these exercises in order. Try the task before opening a reference.
Calculate tokens for 224x224 images using 16x16 patches. Explain whether your count includes a class token.
Calculate flattened RGB patch dimensions and the output shape after projection to an embedding width of 192.
Load a pretrained ViT, use its documented preprocessing, and record predictions on a small labeled image set.
Compare a CNN and ViT with the same data split; disclose different pretraining datasets and compute budgets.
Measure accuracy, peak memory, and latency at supported resolutions; document any positional-embedding adaptation.
High-precision electronics manufacturers requiring automated visual inspection of circuit boards.
Traditional convolutional neural networks struggle with long-range dependencies across complex board layouts, leading to high false-rejection rates for subtle defects.
Vision Transformer (ViT) processes the image as a sequence of patches, allowing the self-attention mechanism to model global relationships between distant components on the board, which improves defect detection accuracy.
The flow from raw image input to final classification output.
Raw circuit board capture
Splitting image into 16x16 segments
Self-attention processing
Defect vs Pass decision
Improved consistency in defect identification across diverse board designs without requiring manual feature engineering.
ViT models require large datasets for pre-training to achieve high performance; check for overfitting by monitoring validation loss on smaller, domain-specific datasets.