Vision Transformers (ViTs) have revolutionized computer vision, often surpassing Convolutional Neural Networks (CNNs) on large-scale benchmarks. However, they suffer from a significant "data hunger" problem. Unlike CNNs, which possess an inherent inductive bias toward locality (the assumption that neighboring pixels are related), ViTs treat images as sequences of patches with no intrinsic spatial structure. Consequently, ViTs must learn spatial common sense from scratch, often requiring massive datasets to converge effectively.
When trained on smaller datasets, such as those containing only a few thousand images of pets or flowers, ViTs frequently underperform or fail to converge. This paper introduces Structured Initialization, a novel approach that jump-starts ViTs by embedding CNN-like locality into their initial weights without requiring architectural changes or pre-training on external data.
Methodology: Baking Locality into Attention
The core idea behind Structured Initialization is to force the initial attention maps of a ViT to behave like random impulse filters. This approach is inspired by the observation that even randomly initialized convolution filters can provide a strong foundation for learning if the network is sufficiently wide.
The authors propose a four-step process to achieve this:
- Theoretical Foundation: By leveraging multiple attention heads, the model can collectively "span" the space of possible convolutional filters.
- Pseudo-Input via Positional Encodings: To solve for the necessary weights without depending on specific image data, the method utilizes the model's own positional encodings as a "pseudo-input."
- Optimization via SVD: The weights for the Query ($Q$) and Key ($K$) matrices are calculated using Singular Value Decomposition (SVD). This ensures the resulting attention map ($M = \text{softmax}(QK^T)$) approximates a specific convolutional impulse pattern.
- Head Diversity: Each attention head is initialized with a unique impulse pattern (e.g., shifting focus one pixel left or several pixels down). This provides the model with a diverse, multi-scale spatial understanding from the very first epoch.
Experimental Evaluation
The researchers evaluated Structured Initialization across a diverse range of data scales and architectures:
- Small-scale: STL-10, Flowers, and Pets (~5,000 training images).
- Medium-scale: Food-101, CIFAR-10, and CIFAR-100 (~50,000 training images).
- Large-scale: ImageNet-1K (>1 million training images).
The method was tested not only on standard ViTs but also on alternative architectures like Swin Transformer and MLP-Mixer, demonstrating its broad applicability across transformer-based models.
Key Results and Insights
The empirical results highlight the effectiveness of providing a "convolutional nudge" at the start of training.
- Performance on Small Data: The most dramatic improvements were seen on small datasets. For instance, on the "Pets" dataset, accuracy soared from a default 26.58% to 50.84%.
- Consistency Across Scales: On medium-sized datasets like CIFAR-100, the method yielded a ~5% absolute gain. Even on the large-scale ImageNet-1K, the method maintained or slightly improved performance (+0.59% for ViT-Base), suggesting that the initial local bias does not hinder the eventual learning of global relationships.
- Efficiency and Convergence: Training curves indicate that models using structured initialization reach high accuracy levels much earlier than those using default or mimetic initialization methods.
The primary insight is that initialization can serve as a form of "soft architecture." By baking structural properties into the starting weights, researchers can preserve the flexibility of the Transformer while mitigating its inherent lack of spatial priors.
Limitations and Future Directions
While highly effective, the method has certain limitations. It relies heavily on positional encodings to serve as a spatial proxy; if a model uses highly non-standard encodings, the effectiveness may diminish. Additionally, the influence of the structured initialization tends to decay in deeper layers as the local signal becomes diluted. Finally, this work focuses on $Q$ and $K$ matrices; future research could explore the initialization of Value ($V$) weights and projection matrices to further enhance the spatial prior.
Summary updated