[Paper Review] Vision Transformers provably learn spatial structure
This paper proposes a theoretical framework showing that Vision Transformers (ViTs) implicitly learn spatial structure through a mechanism called 'patch association,' even without explicit inductive biases for locality. By analyzing a simplified ViT with positional-attention-only attention matrices, the authors prove that gradient descent minimization leads to spatially localized attention patterns, enabling sample-efficient transfer to downstream tasks with similar structure.
Vision Transformers (ViTs) have achieved comparable or superior performance than Convolutional Neural Networks (CNNs) in computer vision. This empirical breakthrough is even more remarkable since, in contrast to CNNs, ViTs do not embed any visual inductive bias of spatial locality. Yet, recent works have shown that while minimizing their training loss, ViTs specifically learn spatially localized patterns. This raises a central question: how do ViTs learn these patterns by solely minimizing their training loss using gradient-based methods from random initialization? In this paper, we provide some theoretical justification of this phenomenon. We propose a spatially structured dataset and a simplified ViT model. In this model, the attention matrix solely depends on the positional encodings. We call this mechanism the positional attention mechanism. On the theoretical side, we consider a binary classification task and show that while the learning problem admits multiple solutions that generalize, our model implicitly learns the spatial structure of the dataset while generalizing: we call this phenomenon patch association. We prove that patch association helps to sample-efficiently transfer to downstream datasets that share the same structure as the pre-training one but differ in the features. Lastly, we empirically verify that a ViT with positional attention performs similarly to the original one on CIFAR-10/100, SVHN and ImageNet.
Motivation & Objective
- Understand how Vision Transformers (ViTs) learn spatial structure despite lacking explicit inductive biases for local connectivity.
- Investigate the implicit inductive bias that enables ViTs to generalize by learning spatially localized attention patterns during training.
- Formalize and prove that a simplified ViT model with positional-attention-only attention matrices implicitly learns spatial structure via gradient descent.
- Demonstrate that this implicit bias enables sample-efficient transfer to downstream tasks sharing the same spatial structure as the pre-training dataset.
- Provide theoretical justification for the empirical observation that ViTs learn local connectivity patterns from random initialization using only gradient-based optimization.
Proposed method
- Define a simplified ViT model where the attention matrix depends solely on positional encodings, termed the 'positional attention mechanism'.
- Construct a synthetic, spatially structured binary classification dataset to isolate the learning of spatial patterns.
- Prove that gradient descent on the population risk (idealized setting) leads to patch association, i.e., attention heads learn to group spatially contiguous patches.
- Establish that this patch association enables generalization and sample-efficient transfer to downstream datasets with the same spatial structure.
- Use invariance and symmetry analysis of attention coefficients during training to prove that the model implicitly learns spatial locality.
- Leverage logarithmic inequalities and concentration bounds (e.g., Chernoff bounds) to control the growth of attention weights and loss during optimization.
Experimental results
Research questions
- RQ1How can Vision Transformers learn spatially localized patterns without explicit inductive biases for local connectivity?
- RQ2What implicit inductive bias enables ViTs to generalize to spatially structured tasks despite random initialization?
- RQ3Can a simplified ViT model with attention dependent only on positional encodings still learn and generalize on spatially structured data?
- RQ4Does the implicit learning of spatial structure (patch association) enable sample-efficient transfer to downstream tasks with similar spatial patterns?
- RQ5What theoretical mechanisms underlie the emergence of spatial locality in ViTs during gradient descent training?
Key findings
- A one-layer single-head ViT with positional-attention-only attention matrices performs patch association during gradient descent, meaning it learns to group spatially contiguous patches.
- Theoretical analysis proves that this patch association occurs in both the idealized population risk minimization and realistic empirical risk minimization settings.
- The model generalizes by implicitly learning spatial structure, even though the underlying optimization problem admits multiple solutions.
- Patch association enables sample-efficient transfer to downstream datasets that share the same spatial structure as the pre-training dataset.
- Empirical results confirm that a ViT with positional attention performs comparably to standard ViTs on CIFAR-10/100, SVHN, and ImageNet.
- Theoretical bounds on attention weight evolution show that the model maintains spatial coherence through invariance and symmetry in attention coefficients during training.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.