What do Vision Transformers Learn? A Visual Exploration

Amin Ghiasi, Hamid Kazemi, Eitan Borgnia, Steven Reich, Manli Shu, Micah Goldblum, Andrew Gordon Wilson, Tom Goldstein · DOI

Introduction

While Convolutional Neural Networks (CNNs) have been the subject of intense visual scrutiny for a decade, Vision Transformers (ViTs) have largely remained "black boxes." This research provides a "looking glass" into their internal logic, revealing that ViTs are not just "CNNs without the convolution," but architectures with fundamentally different ways of processing visual information.

Methodology: Peering into the Transformer

The authors utilize Activation Maximization, a technique where random noise is evolved via gradient descent to maximally excite specific neurons. The "secret sauce" of this approach lies in targeting the Feedforward Network (FFN) layers rather than attention heads. The high-dimensional FFN layers store "disentangled" features that are highly interpretable. To produce clean visualizations, the researchers employed an augmentation recipe including ColorShift, Jitter, and Gaussian smoothing to prevent the optimization from falling into "adversarial" traps.

Visualization of the feature hierarchy in ViTs, progressing from simple edges to complex objects.

Key Insights

Spatial Persistence and the Last-Layer Collapse

One of the most surprising findings is that ViTs maintain a spatial "map" of the image across almost all layers. Even though every patch can attend to every other patch, they choose to keep information local until the very last attention block. It is only in the final layer that spatial information is discarded to create a single global representation for classification.

Background and Shape over Texture

CNNs are notoriously "texture-obsessed," losing significant performance when high-frequency details are removed. In contrast, ViTs are much more resilient, suggesting they rely more on the "shape" or "layout" of objects. Furthermore, ViTs are significantly better at using background information. In tests where the foreground was masked out, ViT-L16 achieved a top-5 accuracy of 33.69%, nearly doubling the 18.69% achieved by a ResNet-50.

Abstract "Concept" Neurons

In models trained with language supervision (CLIP), neurons stop looking like simple objects and start representing abstract ideas. The researchers discovered "concept neurons" that respond to complex themes such as "morbidity" (activated by skulls, tombstones, and zombies) or "music."

Concept neurons in CLIP-trained ViTs responding to the abstract idea of 'morbidity' through various visual cues like skulls and tombstones.

Conclusion

By proving that ViTs are visually interpretable, this work moves the field away from treating Transformers as mysterious black boxes. The findings highlight a clear progression from simple edges to complex objects and abstract concepts, demonstrating that ViTs leverage global context and shape in ways that fundamentally differ from traditional convolutional architectures.

Summary updated

BibTeX
@inproceedings{ghiasi2023what,
  author = {Amin Ghiasi and Hamid Kazemi and Eitan Borgnia and Steven Reich and Manli Shu and Micah Goldblum and Andrew Gordon Wilson and Tom Goldstein},
  title = {{What do Vision Transformers Learn? A Visual Exploration}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=xc5ajsvLzFO},
}
Figure