Conditional Positional Encodings for Vision Transformers
Xiangxiang Chu, Zhi Tian, Bo Zhang, Xinlong Wang, Chunhua, Shen

TL;DR
This paper introduces a dynamic, input-conditioned positional encoding for vision Transformers, improving generalization and translation-invariance, leading to better performance and attention maps similar to learned encodings.
Contribution
It presents a novel conditional positional encoding scheme (CPE) that adapts to input neighborhoods, enhancing vision Transformer flexibility and accuracy.
Findings
CPE generalizes to longer input sequences than seen during training.
CPVT achieves superior performance compared to models with fixed or learned positional encodings.
Attention maps of CPVT are visually similar to those with learned encodings.
Abstract
We propose a conditional positional encoding (CPE) scheme for vision Transformers. Unlike previous fixed or learnable positional encodings, which are pre-defined and independent of input tokens, CPE is dynamically generated and conditioned on the local neighborhood of the input tokens. As a result, CPE can easily generalize to the input sequences that are longer than what the model has ever seen during training. Besides, CPE can keep the desired translation-invariance in the image classification task, resulting in improved performance. We implement CPE with a simple Position Encoding Generator (PEG) to get seamlessly incorporated into the current Transformer framework. Built on PEG, we present Conditional Position encoding Vision Transformer (CPVT). We demonstrate that CPVT has visually similar attention maps compared to those with learned positional encodings and delivers outperforming…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
Taxonomy
TopicsAdvanced Neural Network Applications · Advanced Image and Video Retrieval Techniques · Domain Adaptation and Few-Shot Learning
MethodsCollaborative Preference Embedding · Linear Layer · Depthwise Convolution · Conditional Position Encoding Vision Transformer · Positional Encoding Generator · Conditional Positional Encoding · Absolute Position Encodings · Position-Wise Feed-Forward Layer · Vision Transformer · Feedforward Network
