Neural Processes with Stability

Huafeng Liu, Liping Jing, Jian YuNeurIPS 2023

TL;DR

Neural Processes (NPs) are powerful tools for modeling uncertainty, but they are notoriously sensitive to noisy training data, which hurts their ability to generalize. This paper introduces a theoretical framework and a practical algorithm to make NPs "stable" by forcing the model to co-optimize on the full dataset alongside dynamically generated "hard-to-predict" subsets. The resulting Stable NPs achieve better robustness and accuracy across various tasks without adding significant computational overhead.

Introduction

Neural Processes (NPs) combine the flexibility of neural networks with the uncertainty quantification of stochastic processes (like Gaussian Processes). They are highly efficient because they meta-learn a distribution over functions, allowing them to adapt to new tasks with just a few "context" data points.

However, NPs have a major Achilles' heel: algorithmic instability. Because they are heavily biased toward the meta-dataset they are trained on, small changes in the training data—such as noisy or missing context points—can drastically alter the model's predictions. In machine learning theory, an unstable algorithm usually suffers from poor generalization; minimizing its training error doesn't guarantee a low testing error. While heuristic fixes like ensemble learning or cross-validation exist, they are computationally expensive or require sacrificing precious training data. This paper seeks a mathematically grounded way to build stability directly into the NP training process.

Methodology

The authors tackle the problem by formally defining "algorithmic stability" for NPs and proving that stability bounds can be tightened by manipulating the training data distribution.

Their novel approach relies on identifying and leveraging hard-to-predict subsets. The algorithm works in four main steps:

  1. Pre-train a base NP model on the full meta-dataset to establish a baseline performance.
  2. Identify "easy" data points: Find the subset of data where the model's prediction error (negative log-likelihood) is lower than the average.
  3. Create "hard" datasets: Divide the easy data points into $K$ non-overlapping groups. Subtract each of these easy groups from the full dataset to create $K$ distinct, hard-to-predict subsets.
  4. Joint Optimization: Train the final model by minimizing a weighted sum of the loss on the full dataset and the $K$ hard-to-predict subsets.

Crucially, this method is model-agnostic. It acts as a wrapper that can be applied to any existing NP architecture—turning a Conditional Neural Process (CNP) into a Stable CNP (SCNP), or an Attentive Neural Process (ANP) into a Stable ANP (SANP).

Datasets

The authors evaluated their approach across a diverse set of regression and control tasks:

  • Synthetic 1D Regression: Data generated from Gaussian Processes using RBF, Matern, and Periodic kernels.
  • Image Completion: Treating images as 2D functions using the EMNIST and 32x32 CelebA datasets.
  • System Identification on Physics Engines: A classic Cart-Pole swing-up task simulator to forecast state transitions.
  • Bayesian Optimization: Using GP data with various prior functions.
  • Predator-Prey Models: Training on simulated Lotka-Volterra data and testing on real-world Hudson's Bay hare-lynx population data (a model-data mismatch scenario).

Key Insights and Ideas

  • Stability = Generalization: The authors empirically and theoretically demonstrate that as noise increases in an NP's training set, algorithmic stability drops, directly causing the generalization error to spike.
Stability vs. Generalization
  • Hard data acts as a regularizer: The mathematical proofs show that optimizing over the full dataset plus subsets missing the "easy" points acts as a powerful regularizer. It prevents the model from over-indexing on trivial patterns and forces it to learn more robust representations.
  • Plug-and-play robustness: Because the stability mechanism is applied at the data-sampling and loss-function level, it doesn't require changing the underlying neural architectures of state-of-the-art NPs.

Key Results

  • Superior Noise Resilience: Across 1D regression tasks with varying levels of injected noise (up to 15%), the stable variants (SCNP, SNP, SANP, SConvNP) consistently outperformed their standard counterparts and recent Bootstrapping NP baselines. For example, with 15% noise on RBF data, SANP achieved a target log-likelihood of 0.4356 compared to ANP's 0.4151.
Performance across noise levels
  • Better Real-World Mismatch Handling: In the Predator-Prey task (trained on simulation, tested on real-world data), Stable ConvNP (SConvNP) achieved the best predictive performance, proving the method helps bridge the sim-to-real gap.
  • Physics Engine Accuracy: On the Cart-Pole task, stable NPs achieved higher log-likelihoods and lower Mean Absolute Error (MAE) with noticeably tighter variance than the baselines.
  • Optimal Subsets: An ablation study revealed that dividing the easy data into $K=4$ subsets provides the optimal balance for performance; beyond $K=4$, the performance gains plateau.

Limitations and Future Work

  • Theoretical Scope: The theoretical guarantees provided in the paper are currently based strictly on regression models. The authors note it remains an open question whether these exact stability bounds hold for classification tasks.
  • Conservative Uncertainty: In some specific settings (like 1D regression with a Matern kernel), the stable models exhibited slightly worse calibration errors than standard NPs. The authors suspect their method sometimes produces overly conservative credible intervals, making the model slightly under-confident.
  • Future Work: The authors plan to extend their theoretical framework to cover a wider variety of tasks, specifically classification, to see if the hard-subset regularization holds up.

Summary updated

BibTeX
@inproceedings{liu2023neural,
  author = {Huafeng Liu and Liping Jing and Jian Yu},
  title = {{Neural Processes with Stability}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=PmlNxZoXr4},
}
Figure