Papers › On the Robustness of Vision Transformers to Adversarial Examples

On the Robustness of Vision Transformers to Adversarial Examples

31 Mar 2021ICCV 2021 10arXiv:2104.02610archive 2025-07-28

Kaleel Mahmood, Rigel Mahmood, Marten van Dijk

Recent advances in attention-based networks have shown that Vision Transformers can achieve state-of-the-art or near state-of-the-art results on many image classification tasks. This puts transformers in the unique position of being a promising alternative to traditional convolutional neural networks (CNNs). While CNNs have been carefully studied with respect to adversarial attacks, the same cannot be said of Vision Transformers. In this paper, we study the robustness of Vision Transformers to adversarial examples. Our analyses of transformer security is divided into three parts. First, we test the transformer under standard white-box and black-box attacks. Second, we study the transferability of adversarial examples between CNNs and transformers. We show that adversarial examples do not readily transfer between CNNs and transformers. Based on this finding, we analyze the security of a simple ensemble defense of CNNs and transformers. By creating a new attack, the self-attention blended gradient attack, we show that such an ensemble is not secure under a white-box adversary. However, under a black-box adversary, we show that an ensemble can achieve unprecedented robustness without sacrificing clean accuracy. Our analysis for this work is done using six types of white-box attacks and two types of black-box attacks. Our study encompasses multiple Vision Transformers, Big Transfer Models and CNN architectures trained on CIFAR-10, CIFAR-100 and ImageNet.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2104.02610")

Code

Syntology Ran 8 of 15 code samples harvested from 1 repository linked to this paper; 7 have no recorded run. Of those that ran: 1 ran · violated contract; 5 ran · our draft was wrong; 1 ran · fixture could not drive it; 1 ran with no contract checked.

By repository: official repository: 15 samples from 1 repository, 8 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

MetaMain/ViTRobust officialmentioned in papermentioned on GitHubpytorchBSD-3-Clause report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

15 samples harvested; 8 ran; 0 honoured the contract we drafted; 7 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · violated contract
5ran · our draft was wrong
1ran · fixture could not drive it
1ran
7unverified

Licence: 0 of the 15 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from MetaMain/ViTRobust. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

np2th MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/TransformerModels.py official repository ran · fixture could not drive it BSD-3-Clause (permissive) · 7d8eaf5537f699e4 · report
swish MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/TransformerModels.py official repository ran · our draft was wrong fingerprinted BSD-3-Clause (permissive) · 0f786c407fb1ee4c · report
GradientNormalizedByL1 MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/AttackWrappersWhiteBoxP.py official repository ran fingerprinted BSD-3-Clause (permissive) · 71ded737bf803beb · report
conv1x1 MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/TransformerResNet.py official repository ran · our draft was wrong BSD-3-Clause (permissive) · b0f916df39e78ae5 · report
conv1x1 MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/BigTransferModels.py official repository ran · our draft was wrong BSD-3-Clause (permissive) · ee80cf467065076b · report
conv3x3 MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/TransformerResNet.py official repository ran · our draft was wrong BSD-3-Clause (permissive) · 4e5bf13dbdc4f008 · report
conv3x3 MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/BigTransferModels.py official repository ran · our draft was wrong BSD-3-Clause (permissive) · f01b8d3901f0b289 · report
tf2th MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/BigTransferModels.py official repository ran · violated contract fingerprinted BSD-3-Clause (permissive) · 7023eb86801bb3a3 · report
GetAttention MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/AttackWrappersSAGA.py official repository unverified BSD-3-Clause (permissive) · efa84ad482883af5 · report
resnet1001 MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/ResNetPytorch.py official repository unverified BSD-3-Clause (permissive) · 975c33663559b367 · report
resnet164 MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/ResNetPytorch.py official repository unverified BSD-3-Clause (permissive) · 55fcf6ec82c11e08 · report
resnet56 MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/ResNetPytorch.py official repository unverified BSD-3-Clause (permissive) · 881ff295da65733e · report
validateD MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/DataManagerPytorch.py official repository unverified BSD-3-Clause (permissive) · 72cd943b81f2517e · report
validateDA MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/DataManagerPytorch.py official repository unverified BSD-3-Clause (permissive) · 7d6d811b990ecc66 · report
validateT MetaMain/ViTRobust/VisionTransformersRobustness/VisionTransformersRobustness/DataManagerPytorch.py official repository unverified BSD-3-Clause (permissive) · 4d607f4733726c9d · report

Tasks

Image Classificationimage-classification

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections