Skip to main content
QUICK REVIEW

[Paper Review] On the Adversarial Robustness of Vision Transformers

Rulin Shao, Zhouxing Shi|arXiv (Cornell University)|Mar 29, 2021
Adversarial Robustness in Machine LearningComputer Science50 citations
TL;DR

The paper analyzes adversarial robustness of Vision Transformers (ViTs) versus CNNs and MLP-Mixers, showing ViTs offer stronger robustness, including certified robustness, and investigates frequency-based explanations and training strategies.

ABSTRACT

Following the success in advancing natural language processing and understanding, transformers are expected to bring revolutionary changes to computer vision. This work provides a comprehensive study on the robustness of vision transformers (ViTs) against adversarial perturbations. Tested on various white-box and transfer attack settings, we find that ViTs possess better adversarial robustness when compared with MLP-Mixer and convolutional neural networks (CNNs) including ConvNeXt, and this observation also holds for certified robustness. Through frequency analysis and feature visualization, we summarize the following main observations contributing to the improved robustness of ViTs: 1) Features learned by ViTs contain less high-frequency patterns that have spurious correlation, which helps explain why ViTs are less sensitive to high-frequency perturbations than CNNs and MLP-Mixer, and there is a high correlation between how much the model learns high-frequency features and its robustness against different frequency-based perturbations. 2) Introducing convolutional or tokens-to-token blocks for learning high-frequency features in ViTs can improve classification accuracy but at the cost of adversarial robustness. 3) Modern CNN designs that borrow techniques from ViTs including activation function, layer norm, larger kernel size to imitate the global attention, and patchify the images as inputs, etc., could help bridge the performance gap between ViTs and CNNs not only in terms of performance, but also certified and empirical adversarial robustness. Moreover, we show adversarial training is also applicable to ViT for training robust models, and sharpness-aware minimization can also help improve robustness, while pre-training with clean images on larger datasets does not significantly improve adversarial robustness.

Motivation & Objective

  • Assess and compare the adversarial robustness of ViTs against CNNs and MLP-Mixer across white-box, transfer, and certified settings.
  • Identify sources of ViT robustness through frequency analysis and feature visualization.
  • Explore how architectural choices (convolutions, tokens-to-token blocks, and pure transformer blocks) affect robustness and accuracy.
  • Evaluate the impact of adversarial training and sharpness-aware optimization on ViT robustness.

Proposed method

  • Evaluate robustness under ℓ∞ bounded attacks (PGD, AutoAttack) across a wide set of models including ViT variants, ConvNeXt, MLP-Mixer, and CNNs.
  • Perform frequency-filtered PGD attacks to separate high- and low-frequency perturbations and analyze robustness trends.
  • Use denoised randomized smoothing to certify robustness and compute certified radii as a robustness measure.
  • Visualize first-layer features to relate learned frequency content to robustness and perform ablations with hybrid architectures (CNN+ViT, T2T-ViT, Swin) to study robustness-accuracy trade-offs.
  • Investigate transferability of adversarial examples between ViTs and CNNs and assess pretraining and sharpness-aware optimization effects.

Experimental results

Research questions

  • RQ1Do Vision Transformers exhibit greater adversarial robustness than CNNs and MLP-Mixers under white-box and transfer attacks?
  • RQ2What are the frequency-based factors contributing to ViT robustness, and how do architecture choices influence this?
  • RQ3Can denoised randomized smoothing provide certified robustness advantages for ViTs versus CNNs?
  • RQ4How do training strategies like adversarial training and sharpness-aware minimization affect ViT robustness and clean accuracy?
  • RQ5How does the proportion of transformer versus CNN blocks impact robustness in hybrid architectures?

Key findings

  • ViTs achieve higher robust accuracy (RA) than CNNs under several attacks, e.g., ViT-S/16 RA up to 59.8% under certain conditions versus CNN improvements up to 16.7%.
  • ViTs show reduced sensitivity to high-frequency perturbations compared to CNNs and MLP-Mixer, and high-frequency features correlate with robustness gaps.
  • Denoised randomized smoothing yields significantly better certified robustness for ViTs than CNNs under the same settings.
  • Incorporating CNN or tokens-to-token blocks in ViTs can improve clean accuracy but often reduces adversarial robustness.
  • Increasing transformer block proportion in mixed architectures can improve robustness, though pure transformer size alone does not guarantee it (e.g., ViT-S/16 more robust than ViT-B/16).
  • Pre-training on larger datasets without adversarial training does not significantly boost robustness; adversarial training and sharpness-aware minimization improve ViT robustness and/or clean accuracy.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.