All models

levit_conv_384

A pyramid-shaped vision transformer with a conv stem and attention bias, built for fast inference.

Image classification · 401 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 (36 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
LeViT
Parameters
39.1M
Operations
401
Framework
PyTorch
Recurrent
No
Published
ICCV (arXiv 2021)
Cited by
1,064 (as of 13 November 2026)
Authors
Ben V. Graham, Alaaeldin El-Nouby, Hugo Touvron and others
License
Apache-2.0
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
m5612
Graph hash
480f5fe27afb7db1afc439063f1d7cd61649469eaaf9ce323a85b7d7f4daf757
Skeleton hash
a2a35d1c921530bcdf0693e7eef678d895900efba6a60eb131e18365421df9a7
Architecture hash
c0ff2adc0d0b07f5fed1c825fd6486a8404d9d99f412d2cab0f6402223c7d8d2
Diagram SHA-256
b2425709a582d1a323036756f4dfe43b7520d7f819523d4b4b34ac21bde124c7
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

timm.create_model('levit_conv_384', pretrained=False)

What it is

A conv-form build of the same model; the timm version combines both conv and linear forms.

About this model's family

LeViT is a hybrid neural network for fast inference image classification, designed for the trade-off between accuracy and efficiency in a high-speed regime. The name nods to LeNet: the uniform stack of a Transformer is replaced by a pyramid with pooling. Why it matters: at 80% ImageNet top-1 accuracy, LeViT is 5 times faster than EfficientNet on CPU. It builds upon the ViT architecture and the DeiT training method, folding in components proven useful for convolutional architectures.

The patch embedding is a small convnet: 4 layers of 3x3 convolutions with stride 2 take the channel count from 3 to 32, 64, 128 and 256 while shrinking the resolution. There is no classification token; it is removed in favour of a convnet-style pooling of the last activation map. Positional information comes from a learnt attention bias added directly to the attention maps, instead of a positional embedding at the input. The attention block that downsamples between stages halves the height and width of the activation map, and because of the change in scale it is used without a residual connection. All of LeViT's non-linear activations are Hardswish. Compared with a DeiT block, LeViT spends less time on the MLP component because the expansion factor is halved from four to two.

Training follows DeiT's distillation-driven recipe, with two classification heads: one supervised by the ground-truth classes, the second by a RegNetY-16GF teacher. LeViT-384 is on par with DeiT-Small in accuracy but uses half the number of FLOPs. At the faster end, LeViT-128S is on par with DeiT-Tiny and uses 4 times fewer FLOPs. LeViT-192 and LeViT-256 have about the same accuracies as EfficientNet B2 and B3 but are 5 and 7 times faster on CPU. In the ablations, flattening the pyramid into a straight stack at the same FLOP count forces the network width down, leaving a model with few parameters and a very low final accuracy. The timm implementation traced here, adapted from the official facebookresearch/LeViT code, combines both conv and linear forms of the model.

Key idea. A multi-stage, pyramid-shaped vision transformer that uses attention as its downsampling mechanism, with a convolutional patch descriptor, a learnt per-head attention bias in place of positional embeddings, and a redesigned Attention-MLP block, all tuned for inference speed.

  • levit
  • levit-128
  • levit-256
  • levit-384
  • vision transformer in convnet's clothing
  • fast inference image classification
  • attention bias
  • hybrid transformer
  • timm

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

Cite the paper

@misc{graham2021levitvisiontransformerconvnets,
      title={LeViT: a Vision Transformer in ConvNet's Clothing for Faster Inference}, 
      author={Ben Graham and Alaaeldin El-Nouby and Hugo Touvron and Pierre Stock and Armand Joulin and Hervé Jégou and Matthijs Douze},
      year={2021},
      eprint={2104.01136},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2104.01136}, 
}