arXiv:2605.23719cs.CVcs.AI2026-05

用数学构造的2D位置编码提升ViT对图像空间结构的建模能力

Weierstrass Positional Encoding for Vision Transformers

论文配图:Weierstrass Positional Encoding for Vision Transformers
图 1 · 摘自论文原文
  • 将图像块坐标映射到复平面,用魏尔斯特拉斯函数生成四维位置特征
  • 在多个数据集上实现稳定性能提升,且无额外计算开销
  • 适合需要精确空间建模的视觉任务,如医学图像分析

视觉变换器在计算机视觉中取得显著成功,但其常用的可学习一维位置编码在图像块展平后削弱了固有的二维空间结构。现有位置编码通常缺乏几何约束,且不保持欧氏空间距离与序列索引距离之间的单调关系,限制了ViT对空间邻近先验的利用。受周期性在位置编码中的有效性启发,我们提出魏尔斯特拉斯椭圆位置编码(WePE),一种在复数域中编码二维坐标的数学基础方法。WePE将归一化二维图像块坐标映射至复平面,利用魏尔斯特拉斯椭圆函数及其导数构建紧凑的四维位置特征。双周期性提供了2D位置的合理表示,其内在格点结构天然匹配图像块网格的规则几何。非线性几何特性更真实地建模空间距离关系,而代数加法公式可直接从绝对编码推导任意块对间的相对位置信息。WePE为即插即用且分辨率无关,可无缝集成至现有ViT中。大量实验表明,WePE在多数设置下带来一致性能提升;通过预计算查表,这些改进几乎不引入额外计算或内存开销。额外的分析与消融研究进一步验证了该方法的有效性。

原文摘要 · Abstract (English)

Vision Transformers have achieved remarkable success in computer vision, but their common use of learnable one-dimensional positional encodings weakens the inherent two-dimensional spatial structure of images after patch flattening. Existing positional encodings often lack geometric constraints and do not preserve a monotonic relationship between Euclidean spatial distances and sequential index distances, limiting ViTs' ability to exploit spatial proximity priors. Motivated by the usefulness of periodicity in positional encoding, we propose Weierstrass elliptic Positional Encoding (WePE), a mathematically grounded method for encoding two-dimensional coordinates in the complex domain. WePE maps normalized 2D patch coordinates onto the complex plane and constructs compact four-dimensional positional features using the Weierstrass elliptic function and its derivative. The double periodicity provides a principled representation of 2D positions, and its intrinsic lattice structure naturally matches the regular geometry of image patch grids. Its nonlinear geometric properties help model spatial distance relationships more faithfully, while the algebraic addition formula enables relative positional information between arbitrary patch pairs to be derived directly from their absolute encodings. WePE is plug-and-play and resolution-agnostic, allowing seamless integration into existing ViTs. Extensive experiments show that WePE brings consistent performance gains in most settings. With precomputed lookup tables, these improvements introduce no noticeable computational or memory overhead. Additional analyses and ablation studies further validate the effectiveness of the proposed method.

视觉Transformer位置编码几何建模

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。