LaPE: Layer-adaptive Position Embedding for Vision Transformers with Independent Layer Normalization

Runyi Yu, Zhennan Wang, Yinhuai Wang, Kehan Li, Chang Liu, Haoyi Duan, Xiangyang Ji, Jie Chen

Abstract

Standard Vision Transformers (ViTs) typically integrate position information at the very first layer, forcing position embeddings (PE) to share normalization parameters with image tokens. This coupling creates a normalization bottleneck that mutes spatial expressiveness. This paper introduces LaPE (Layer-adaptive Position Embedding), which breaks this coupling by providing PE with its own independent Layer Normalization at every layer and passing it progressively through the network. This simple architectural change allows ViTs to develop hierarchical, layer-specific spatial awareness, leading to significant performance gains across classification, detection, and segmentation with negligible computational overhead.

The Problem: The Normalization Bottleneck

Vision Transformers are inherently "bag-of-words" models that require explicit position embeddings to understand spatial relationships. The standard approach adds a PE to patch tokens before they enter the transformer blocks. However, the authors identify two major flaws in this "default joining" method:

  1. Shared Normalization: In standard ViTs, tokens and PEs are summed and passed through a shared Layer Normalization (LN). Because tokens and PEs have different statistical distributions, the LN's affine parameters (scale and shift) must compromise between the two, effectively "muting" the expressiveness of the spatial information.
  2. Monotonic Spatial Information: By adding the same PE at the start and letting it propagate via skip connections, the model is restricted to a static spatial representation. It cannot easily adjust its spatial focus (e.g., moving from local neighbor-matching to global context) as it moves from shallow to deep layers.
Comparison of default PE joining vs. Independent LN (LaPE) and their resulting spatial correlation maps.

The LaPE Architecture

To address these limitations, LaPE introduces two key architectural shifts:

  • Independent Layer Normalization: Instead of $LN(Token + PE)$, LaPE uses $LN_{token}(Token) + LN_{PE}(PE)$. By giving the position embedding its own dedicated set of learnable parameters $(\gamma, \beta)$ in each layer, the model can adaptively scale and shift spatial information without interfering with the image content.
  • Progressive PE Delivery: Instead of adding the PE once at the beginning, LaPE passes the PE serially from layer to layer: $\omega_l = LN_{\omega|l-1}(\omega_{l-1})$. This allows the spatial signal to evolve dynamically throughout the network hierarchy.

Mathematically, the authors use reparameterization to show that the default method forces a trade-off between coefficients that govern how much the model "listens" to tokens versus positions. LaPE removes this constraint, allowing the model to independently tune these weights at every stage.

Architectural details of (a) Layer Normalization, (b) standard ViT, and (c) ViT with LaPE.

Key Insights and Results

LaPE consistently outperformed the default PE method across a wide range of standard computer vision benchmarks:

  • Image Classification: Improved ImageNet-1K accuracy for DeiT-Ti by +1.57% and DeiT-S by +0.54%.
  • Object Detection & Segmentation: Gained +0.7 box AP on COCO and improved ADE20K mIoU by +1.37 for the tiny Segmenter model.
  • Hierarchical Evolution: Visualization reveals that LaPE-equipped models develop a "local" spatial focus in early layers that transitions to a "global" focus in deeper layers. In contrast, the default method remains monotonic and rigid.
  • 1-D to 2-D Transformation: LaPE allows 1-D sinusoidal PEs to transform into 2-D spatial correlation maps, which are significantly more natural for image data.

Efficiency and Convergence

Because Layer Normalization is computationally inexpensive, LaPE provides a "free" performance boost. For a DeiT-Ti model, the parameter increase is a mere 0.08%. Furthermore, LaPE-based models converge faster; for example, a LaPE model at 100 epochs often matches the accuracy of a default model at 150+ epochs. This suggests that the way we join PE to tokens is more critical than the type of PE used, as LaPE significantly shrinks the performance gap between fixed sinusoidal and learnable PEs.

Summary updated

BibTeX
@inproceedings{yu2023lape,
  author = {Runyi Yu and Zhennan Wang and Yinhuai Wang and Kehan Li and Chang Liu and Haoyi Duan and Xiangyang Ji and Jie Chen},
  title = {{LaPE: Layer-adaptive Position Embedding for Vision Transformers with Independent Layer Normalization}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2023},
  doi = {10.1109/iccv51070.2023.00541},
}

Loading related content...

Figure