All models

vit_h_14

Vision Transformer: a Transformer encoder that classifies an image from a sequence of patch embeddings.

Image classification · 144 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (21 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
ViT
Parameters
298.3K
Operations
144
Framework
PyTorch
Recurrent
No
Source
torchvision 0.21.0
License
BSD-3-Clause
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m10995
Graph hash
5ac4badeb16ae2ac7c5b4b6b245bf2a096f65ed4b6b635a27b3387609484819e
Skeleton hash
ad807a0a931f7a8135986b7bc30d871a500400529661f4efb38633b4416bdb4c
Architecture hash
516c7903503359fcef6b86c61734a7b70bff49815052d801043016999dcb9c8a
Diagram SHA-256
86ef513fce0daa31e4951adcc77c0362d1b6a4fa5f38b0e155a2337b44a04b37
TorchLens version
2.35.3
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

menagerie.classics.resid_slice_e:build_vit: build({})

What it is

This model carries the name vit_h_14, which in the paper's notation denotes the Huge size with 14 × 14 input patches. Huge is the size the paper adds above the Base and Large sizes it adopts from BERT.

About this model's family

The Vision Transformer (ViT) is a pure transformer applied directly to sequences of image patches for image classification. The paper's argument is that vision models do not need to rely on CNNs. An image is split into patches, and the patches are treated the same way as word tokens in a language model.

The design follows the original Transformer as closely as possible. A learnable embedding is prepended to the sequence of embedded patches, and a classification head is attached to its state at the encoder's output. Learnable 1D position embeddings are added to the patch embeddings to retain positional information. Inside the encoder, layer normalization is applied before every block and residual connections after every block. The paper notes that Transformers lack inductive biases inherent to CNNs, such as translation equivariance and locality, and do not generalize well when trained on insufficient data.

The paper defines Base, Large and Huge sizes with 12, 24 and 32 layers. Models with a smaller patch size see a longer sequence and are computationally more expensive. The paper reports that its best model reaches 88.55% accuracy on ImageNet and 94.55% on CIFAR-100. In torchvision, all the model builders rely on one VisionTransformer base class, and by default no pre-trained weights are used.

Key idea. The paper shows that a pure transformer applied directly to sequences of image patches can classify images without relying on CNNs.

  • Vision Transformer
  • ViT
  • vit_b_16
  • vit_b_32
  • vit_l_16
  • vit_l_32
  • vit_h_14
  • An Image is Worth 16x16 Words
  • image classification
  • image patches

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.