MONA explainer 9 min read

ViT vs CNN: How a Vision Transformer Differs from a Convolutional Network

Mona compares a pixel dog read two ways, by a sliding filter and by tiles linked to every tile: "assumed or learned?"

ViT vs CNN: what is the difference, and which should you choose?

ViT vs CNN comes down to assumptions: a CNN (convolutional neural network, which slides small filters over an image) assumes nearby pixels belong together, while a ViT (vision transformer) assumes almost nothing and learns it from data.

With little data and no pre-trained model, a CNN is the safer start (our reading of tests down to 1.3 million images); after large pre-training, the two land close.

It helps you pick a model for an app that sorts photos, such as a dog photo.

A common route to an image model is three steps: choose an architecture, start from a pre-trained model (one already trained on a large set of images), then fine-tune it (keep training on your own photos).

The vision transformer vs CNN choice is the first step. A vision transformer runs a transformer, a design made for text, on pieces of an image.

How a vision transformer reads an image and convolutional neural networks explain each one. The step after is Max's guide to fine-tuning a small ViT on pet photos.

A CNN has two assumptions built in, that nearby pixels belong together and that a pattern means the same wherever it appears. A ViT has almost none and learns them from examples.

What a CNN assumes and a ViT does not

A CNN reads the dog photo with filters: small grids of weights (the numbers a network learns in training), each covering a few neighbouring pixels, the dots of colour in an image. The same filter slides over every position, so an ear is found the same way in any corner.

These are two inductive biases, assumptions built into a design: locality (nearby pixels belong together) and translation equivariance (shift the dog, and the filter output shifts with it).

A ViT cuts the photo into patches, small square pieces, and turns each into a token, a list of numbers, through a linear step (weighted sums of its pixels), the patch embedding.

Self-attention lets each token score every other token and add in their numbers by that score, so from the first layer an ear patch can use the tail at the far edge.

The first ViT paper says all spatial relations between patches “have to be learned from scratch”. Attention mechanism covers it.

A CNN assumes nearby pixels belong together; a ViT lets every patch score every other patch and learns those relations from data.

Why ViTs needed more data

The first ViT paper (Dosovitskiy et al., 2020) measured the price. Pre-trained on ImageNet-1k, about 1.3 million pre-training images, with a plain recipe (training settings), ViTs scored a few points of accuracy (the share of test images labelled correctly) below standard CNNs (ResNets) of comparable size.

With 14 million to 300 million pre-training images, ViTs caught up or pulled ahead. The authors’ summary: “large scale training trumps inductive bias.”

How the gap narrowed from both sides

DeiT (Touvron et al.) trained a ViT with a stronger recipe, including heavy data augmentation (random changes to training photos), and, by the authors’ own account, almost closed the gap to CNNs when training on ImageNet alone. So part of the 2020 gap was likely the recipe.

ConvNeXt (Liu et al.) rebuilt a ResNet with design choices and a training recipe taken from vision transformers. A pure CNN, it matched Swin transformers of similar size, on ImageNet-1k and after larger pre-training.

How to choose

Your situationStart with (our reading)
Pre-trained models of both kinds existEither; test both on your photos
No pre-trained model, few labelled photos of your ownA CNN; its assumptions stand in for examples (we found no measurement below ImageNet-1k size)
Large images, or detection (boxes around objects)Either; for very large images, a ViT with small attention windows

If you only wanted ViT vs CNN and which to choose, you can stop here.

What higher resolution costs a ViT

The dog photo of 224 x 224 pixels, cut into 16 x 16-pixel patches, gives 196 patches. At 448 pixels a side there are 784 patches, four times as many.

Self-attention scores every pair of patches, so its table of scores grows 16 times: from 38,416 to 614,656 entries. But ViT-B/16, the base ViT with 16-pixel patches, spends most of its compute on steps applied to each token alone, and those grow four times.

So the total arithmetic (FLOPs) grows about 4.5 times, not 16, by our estimate from the formulas in the ViT and Swin papers. At 1024 pixels it is about 38 times the 224 figure, with attention near half of it.

At moderate sizes, a ViT tracks the pixel count almost like a CNN. From 224 to 384 pixels, the timm library (a collection of PyTorch image models) counts 3.16 times the operations for ViT-B/16, and 2.94 times, exactly the growth in pixels, for the CNN ConvNeXt-B.

FlashAttention, a 2022 attention algorithm, computes the same attention without storing the whole score table, so its memory grows only linearly with the number of tokens.

What each one learns inside

Raghu et al. (NeurIPS 2021) compared ViTs and ResNets pre-trained on JFT-300M, Google’s internal set of about 300 million labelled images. ViT layers were more uniform and took in more global information low down. Their measure, CKA, scores how similar the outputs of two layers are as one number: it shows that the two differ; it does not rank them.

With ImageNet-1k alone, the lower ViT layers (ViT-L/16 and ViT-H/14) did not learn to attend locally; with JFT-300M they did. Position embeddings, numbers added to each token for where its patch was, also start with no 2D information and learn it (ViT paper; see patch embeddings, the class token and position embeddings).

Large images and dense tasks

Dense tasks label every pixel or box every object, on large inputs. The Swin transformer (2021) limits attention to small windows of patches, so its cost grows linearly with image size.

ViTDet (2022), an object detector, fine-tuned plain ViTs on 1024 x 1024 images for object detection, with window attention and a few cross-window blocks (global attention or convolution). It competed with the leading detectors, although their backbones all shrink the image in stages and a plain ViT does not.

Its ViTs were pre-trained as masked autoencoders: self-supervised training that hides about 75 % of the patches and restores them, so the pre-training images need no labels. DINOv3 follows DINOv2 as self-supervised pre-trained models: Meta released it in 2025 as distilled ViTs and ConvNeXts (smaller models trained to copy a larger one), so pre-trained models of both kinds exist.

Other model designs, such as state-space models and mixture of experts, have their own topic pages.

Published measurements

Measured resultConditionsWhat it tells you
ViT-B/32 (32-pixel patches) much worse than ResNet-50 on 9 million images, better from 90 millionViT paper, 2020; subsets of JFT-300MIn that setup, the crossover sits between those sizes
ViT used 2 to 4 times less pre-training compute than ResNets to reach the same average score over five datasetsViT paper; JFT-300MAt that scale, the ViT was cheaper to pre-train
DeiT-B: 81.8 % at 224 pixels and 83.1 % at 384 without a teacher; 85.2 % with one (a CNN whose predicted labels it also learned; 384 pixels, 1,000 passes over the data)DeiT, 2021; ImageNet-1k onlyThe 85.2 % model beat ViT-B/16 pre-trained on JFT-300M at 384 pixels (84.15 %)
ViT-B/16 and ViT-L/16 pre-trained on ImageNet-21k (about 14 million images) matched or beat the same models on JFT-300M, a set about 20 times largerAugReg (Steiner et al., 2021); strong augmentation, longer trainingRecipe and compute stand in for data, but “cannot hold for arbitrarily small datasets”
ViT-Huge as a masked autoencoder: 87.8 % after fine-tuning at 448 pixelsHe et al., 2021; ImageNet-1k, no labels in pre-trainingWithout extra data, pre-training without labels gave the best ImageNet-1k-only result then
ConvNeXt above Swin at three model sizes, by under one pointConvNeXt, 2022; ImageNet-1k, 224 pixels, matched computeA modernised CNN matches a vision transformer
ConvNeXt-B about 3.0 points above ViT-B/16PyTorch’s torchvision v0.29.2 weights (October 2026); ImageNet-1k only, 224 pixelsWith each model’s own recipe, the CNN is ahead on ImageNet-1k only
ConvNeXt-B 0.7 points above ViT-B/16timm v1.0.31 results (November 2026); ImageNet-21k pre-training, 224 pixelsIn timm: 4.7 on ImageNet-1k only, 0.7 with larger pre-training
ViT-B/16 about 2,990 images per second, ConvNeXt-B about 2,100one RTX 4090 GPU, inference, batches of 1,024; mixed precision, 224 px, timm v1.0.31 benchmark file (January 2026)On this GPU, this ViT ran faster than this CNN; we found no CPU measurements; the phone test is in the panel below

When it breaks: The ViT paper’s subset test found ViT-B/32 much worse than ResNet-50 at 9 million images; no source we read measures a ViT trained from scratch on a small labelled set below ImageNet-1k size.

At 1024 x 1024 for detection, ViTDet called global attention throughout the backbone “prohibitive in memory and … slow”.

Cheat sheet

The article on one page: open it full size, save it or share it.

Cheat sheet: what a CNN assumes and a ViT does not, how to choose, data a ViT needed, and the CNN's lead in 2026
PNG

AI-assisted content, human-reviewed. Images AI-generated. Editorial Standards · Our Editors