Learning High-Frequency Functions Made Easy with Sinusoidal Positional Encoding

Chuanhao Sun, Zhihang Yuan, Kai Xu, Luo Mai, Siddharth N, Shuo Chen, Mahesh K. Marina

Introduction

Coordinate-based neural networks, particularly Multi-Layer Perceptrons (MLPs), have become a cornerstone of modern computer vision and signal processing, powering breakthroughs in Neural Radiance Fields (NeRF) and audio synthesis. However, these models inherently suffer from "spectral bias," a phenomenon where neural networks prioritize learning low-frequency, smooth functions while struggling to capture sharp, high-frequency details.

To mitigate this, researchers traditionally employ Positional Encoding (PE), mapping low-dimensional coordinates into a high-dimensional space using fixed Fourier features. While effective, standard PE requires extensive manual hyperparameter tuning and lacks the adaptivity needed for complex, data-scarce scenarios. This paper introduces Sinusoidal Positional Encoding (SPE), a "plug-and-play" modification that enables models to learn high-frequency details adaptively and efficiently.

The Challenge of Spectral Bias and Manual Tuning

Standard Positional Encoding uses a fixed set of sine and cosine waves to represent input coordinates. This approach faces two primary hurdles:

  1. Manual Hyperparameter Optimization: Engineers must manually select the number of frequency components ($L$). An insufficient $L$ results in blurry outputs, while an excessively high $L$ leads to overfitting and high-frequency artifacts.
  2. Stationarity: Fixed frequencies do not adapt to the specific characteristics of the input data. This lack of flexibility is particularly detrimental in "few-view" synthesis, where a model must reconstruct a 3D scene from a very limited number of images (e.g., eight views). In these cases, fixed PE often fails to align the model's inductive bias with the underlying signal.

Methodology: Sinusoidal Positional Encoding (SPE)

SPE addresses these limitations by making the frequency components trainable and adaptive. Rather than attempting to learn high frequencies from scratch—which presents an infinite and unstable search space—SPE utilizes standard PE as an "anchor."

The SPE Formula

The core mechanism of SPE involves passing the output of a standard PE layer through a sinusoidal activation function with a trainable weight matrix ($\omega$):

$$SPE(x) = \sin(\omega PE(x))$$

By embedding fixed positional encodings within a trainable sine activation, the model can search for optimal frequencies within a bounded, stable space. This architectural change is remarkably simple to implement, often requiring only a single line of code change: replacing the initial ReLU activation in an MLP with a Sine activation.

Why SPE Works

  • Bounded Search Space: The use of PE as an anchor constrains the optimization process, preventing the instability often associated with learning frequencies directly.
  • Input-Conditioned Adaptivity: Unlike static PE, SPE learns which frequency bands are most relevant based on the input data, allowing for localized detail refinement.
  • Automated Frequency Selection: SPE effectively eliminates the "$L$ headache." Researchers found that by setting a high initial $L$, the trainable weights $(\omega)$ automatically select the necessary frequency components, effectively automating the hyperparameter tuning process.

Experimental Evaluation

The authors evaluated SPE across three distinct domains to demonstrate its versatility:

  1. 3D View Synthesis (Few-View NeRF): Using the Blender synthetic dataset, the researchers tested the model's ability to reconstruct 3D objects from only eight input views.
  2. Text-to-Speech (TTS): SPE was integrated into the FastSpeech architecture to evaluate its impact on audio fidelity and high-frequency alignment.
  3. 1D Regression: Synthetic data was used to analyze the convergence behavior and Neural Tangent Kernel (NTK) properties of the proposed method.

Key Results

Superior Performance in Few-View Scenarios

In the challenging few-view NeRF task, SPE outperformed the current state-of-the-art method, FreeNeRF. The method achieved a 3% improvement in PSNR and a 1.7% increase in SSIM. Qualitatively, this resulted in significantly sharper textures and a reduction in visual artifacts on complex geometries, such as the "Blender Chair."

Accelerated Convergence

In 1D regression tasks, SPE demonstrated 2× faster convergence compared to standard PE. In specific instances, the training loss achieved by SPE was two orders of magnitude lower than the baseline, highlighting its efficiency in capturing the target signal.

Enhanced Audio Fidelity

When applied to the FastSpeech architecture, SPE improved the alignment of high-frequency audio details with ground-truth data. This led to synthesized speech that was crisper and more natural-sounding than models using standard positional encodings.

Discussion and Limitations

While SPE offers significant advantages in learning efficiency and adaptivity, it does introduce some computational overhead during the forward pass compared to grid-based or hash-based methods like InstantNeRF. Furthermore, while SPE excels in data-scarce and few-view scenarios, its performance on massive, city-scale datasets remains an area for future investigation.

In conclusion, Sinusoidal Positional Encoding provides a robust, easy-to-implement solution to the spectral bias problem. By making positional encoding trainable within a bounded sinusoidal space, it removes the need for manual frequency tuning and provides a powerful inductive bias for high-fidelity signal reconstruction.

Summary updated

BibTeX
@inproceedings{sun2024learning,
  author = {Chuanhao Sun and Zhihang Yuan and Kai Xu and Luo Mai and Siddharth N and Shuo Chen and Mahesh K. Marina},
  title = {{Learning High-Frequency Functions Made Easy with Sinusoidal Positional Encoding}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=qqPL0DkcrI},
}
Figure