[Paper Review] Understanding Gaussian Attention Bias of Vision Transformers Using Effective Receptive Fields
The paper analyzes how Vision Transformers acquire spatial understanding via effective receptive fields, shows positional embeddings contribute to order-awareness, and proposes Gaussian attention bias to improve ViT performance across tasks and datasets.
Vision transformers (ViTs) that model an image as a sequence of partitioned patches have shown notable performance in diverse vision tasks. Because partitioning patches eliminates the image structure, to reflect the order of patches, ViTs utilize an explicit component called positional embedding. However, we claim that the use of positional embedding does not simply guarantee the order-awareness of ViT. To support this claim, we analyze the actual behavior of ViTs using an effective receptive field. We demonstrate that during training, ViT acquires an understanding of patch order from the positional embedding that is trained to be a specific pattern. Based on this observation, we propose explicitly adding a Gaussian attention bias that guides the positional embedding to have the corresponding pattern from the beginning of training. We evaluated the influence of Gaussian attention bias on the performance of ViTs in several image classification, object detection, and semantic segmentation experiments. The results showed that proposed method not only facilitates ViTs to understand images but also boosts their performance on various datasets, including ImageNet, COCO 2017, and ADE20K.
Motivation & Objective
- Investigate how ViTs understand spatial structure through effective receptive fields (ERF).
- Show that order-awareness arises from trained positional embeddings rather than pre-defined position cues.
- Propose a Gaussian attention bias to instantiate spatial understanding from the start of training.
- Demonstrate that Gaussian attention bias improves ViT performance on classification, detection, and segmentation tasks across multiple datasets.
Proposed method
- Compute and analyze the ERF of ViTs using gradients averaged over many images to reveal patch contributions.
- Examine the role of absolute and relative positional embeddings (APE, RPE) in shaping ERF and how reinitializing them affects activity.
- Propose a Gaussian attention bias B_Gaussian_l added to the attention score as in softmax(QK^T/√D + B_rel,l + B_Gaussian,l).
- Construct B_Gaussian,l by stacking sliced 2D Gaussians parameterized by A_l and σ_l, ensuring non-negative amplitudes and layer-wise sharing across heads.
- Make B_Gaussian,l differentiable and optionally learn A_l and σ_l while preserving compatibility with existing RPEs (RelPosBias or RelPosMlp).
- Evaluate ViT variants on ImageNet-1K and other datasets; measure top-1 accuracy gains with Gaussian attention bias.

Experimental results
Research questions
- RQ1Does ViT's order-awareness primarily emerge from trained positional embeddings rather than inherent SA structure?
- RQ2Can injecting a Gaussian attention bias into relative position encoding induce spatial understanding from initialization and improve downstream tasks?
Key findings
- ERFs of ViTs concentrate on the target patch with partial usage of neighboring patches, indicating spatial understanding emerges during training.
- Untrained RPE yields distance-insensitive ERFs; learned RPEs converge to a 2D Gaussian-like pattern facilitating near-far patch discrimination.
- Adding Gaussian attention bias improves ViT performance across ImageNet-1K, Oxford-IIIT Pet, Caltech-101, Stanford Cars, and Stanford Dogs, with gains such as +0.157 (S/16), +0.362 (B/16) on ImageNet-1K.
- Gaussian bias also yields modest improvements for object detection and semantic segmentation tasks (e.g., Swin-S with RelPosBias: AP_box +0.11, AP_mask +0.10, mIoU +0.25, aAcc +0.27).
- The learned σ_l adapts across datasets, enabling flexible ERF sizing; last two layers may not learn a Gaussian pattern, suggesting layer-wise variation in behavior.
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.