All models

vit_l_32

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

Image classification · 874 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 (15 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
306.5M
Operations
874
Framework
PyTorch
Recurrent
No
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
m11012
Graph hash
312b7ab6e43a1e45ee77647e1cbae930abbd4cdb56eb26673b131f87ffa8984c
Skeleton hash
0624a569336aad3bdc4273f2d71fd176de7720f2dcbaf033bb7056b38984a01c
Architecture hash
566882a2e6b41bee7f37388757d6d19dff83b53be742a5e2076eb380cac0baef
Diagram SHA-256
83aa33cd07faf48a31c5797b96fc3785d50087b05954da6e6540c370967ced2a
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

torchvision.models.get_model('vit_l_32', weights=None)

What it is

This model is built by torchvision's vit_l_32 builder. In the paper's notation, that name denotes the Large size with 32 × 32 input patches.

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.