Structured Initialization for Attention in Vision Transformers
Jianqiao Zheng, Xueqian Li, Simon Lucey
TL;DR
This work tackles ViTs’ data-inefficiency on small datasets by recasting CNN inductive bias as a structured initialization for ViT attention. It introduces convolution-inspired impulse filters initialized through an optimization over a pseudo input, yielding an attention map initialization $M_{\text{init}}$ that approximates a convolutional impulse matrix $\mathbf{H}_{\text{impulse}}$ via $M_{\text{init}} = \mathrm{softmax}(\tilde{\mathbf{X}}\mathbf{Q}_{\text{init}}\mathbf{K}_{\text{init}}^{T}\tilde{\mathbf{X}}^{T}) \approx \mathbf{H}_{\text{impulse}}$. The optimization for $\mathbf{Q}_{\text{init}}$ and $\mathbf{K}_{\text{init}}$ uses gradient descent with a fixed pseudo input and MSE loss, serving as a fast surrogate for SVD and avoiding offline pretraining. Empirically, the impulse-initialized ViTs achieve state-of-the-art data-efficient performance on CIFAR-10/100 and SVHN, while maintaining strong performance on ImageNet-1K, and provide interpretable attention maps that resemble convolutional structure. This initialization preserves the flexibility of transformers for large-scale data and offers a principled alternative to mimetic or architectural approaches for injecting CNN-like inductive bias.
Abstract
The training of vision transformer (ViT) networks on small-scale datasets poses a significant challenge. By contrast, convolutional neural networks (CNNs) have an architectural inductive bias enabling them to perform well on such problems. In this paper, we argue that the architectural bias inherent to CNNs can be reinterpreted as an initialization bias within ViT. This insight is significant as it empowers ViTs to perform equally well on small-scale problems while maintaining their flexibility for large-scale applications. Our inspiration for this ``structured'' initialization stems from our empirical observation that random impulse filters can achieve comparable performance to learned filters within CNNs. Our approach achieves state-of-the-art performance for data-efficient ViT learning across numerous benchmarks including CIFAR-10, CIFAR-100, and SVHN.
