Rethinking Positional Encoding

Jianqiao Zheng, Sameera Ramasinghe, Simon Lucey

Abstract

Coordinate-based Multi-Layer Perceptrons (MLPs) often struggle with "spectral bias," failing to capture high-frequency details from raw coordinates. While positional encoding via Fourier features is a common remedy, its underlying mechanics have remained largely empirical. This paper moves beyond the "Fourier-only" perspective, demonstrating that positional encoding effectiveness is governed by a fundamental trade-off between stable rank (memorization) and distance preservation (generalization). By reframing positional encoding as a sampling of shifted basis functions, we show that non-Fourier alternatives—specifically Gaussian embeddings—can match or exceed standard performance while offering greater stability and interpretability.

Introduction: The Spectral Bias Problem

In modern computer vision, coordinate-based MLPs power critical applications like Neural Radiance Fields (NeRF). However, these networks inherently favor low-frequency signals, a phenomenon known as spectral bias. To capture sharp edges and fine textures, researchers typically project coordinates into a high-dimensional space using sine and cosine functions (Fourier features).

While effective, this approach often feels like "black magic," relying on stochastic frequency sampling that is sensitive to hyperparameters. This paper investigates whether Fourier is the only viable path and identifies the core mathematical principles that define a "good" encoding.

Methodology: Shifted Basis Functions

The authors propose a generalized framework: positional encoding is the systematic sampling of shifted continuous basis functions. Instead of focusing solely on frequencies, they analyze functions $\psi(t, x)$ where the coordinate position determines the "shift."

Comparison of Gaussian (a, b) and Fourier (c, d) basis functions as shifted signals.

This framework reveals two mathematical pillars governing performance:

  1. Stable Rank: Measures the embedding matrix's expressive power. High stable rank enables the MLP to memorize training data and high-frequency details.
  2. Distance Preservation: Measures how well the embedding maintains Euclidean distances between coordinates. This property is crucial for the network's ability to generalize and interpolate at unseen locations.

The Gaussian Embedder

Leveraging this theory, the authors introduce the Gaussian Embedder. By using Gaussian signals instead of sines and cosines, they can precisely tune the rank-distance trade-off by adjusting the standard deviation ($\sigma$). Unlike Random Fourier Features (RFF), this approach is deterministic, avoiding the volatility of random frequency sampling.

Key Insights and Results

The research highlights that positional encoding is a balancing act. An encoding with excessively high rank (like one-hot encoding) leads to perfect memorization but zero generalization. Conversely, low-rank encodings (like single low-frequency waves) generalize too much, resulting in blurry reconstructions.

Experimental Validation

The theory was tested on 1D signals (image rows), 2D natural images, and synthetic random signals. Key findings include:

  • Performance Parity: Gaussian embeddings achieve PSNR scores equivalent to or better than RFF across various tasks.
  • Enhanced Stability: Especially at lower embedding dimensions, the Gaussian approach exhibits significantly lower variance than RFF, which is prone to "unlucky" frequency samples.
  • Efficiency: Gaussian embeddings often require fewer dimensions to reach target performance levels compared to stochastic Fourier methods.

Conclusion and Future Work

By rethinking positional encoding through the lens of shifted basis functions, this work demystifies why Fourier features work and opens the door to task-specific encodings. While scaling to very high-dimensional inputs remains a challenge, the Gaussian embedder provides a more stable, theoretically grounded alternative to traditional methods. Future research may explore how to choose basis functions based on the specific spatial properties of a given dataset.

Summary updated

BibTeX
@misc{zheng2021rethinking,
  author = {Jianqiao Zheng and Sameera Ramasinghe and Simon Lucey},
  title = {{Rethinking Positional Encoding}},
  year = {2021},
  eprint = {2107.02561},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.02561},
}
Figure