NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Attentive Neural Processes

Hyunjik Kim, Andriy Mnih, Jonathan Schwarz, Marta Garnelo, S. M. Ali Eslami, Dan Rosenbaum, Oriol Vinyals, Yee Whye Teh

Abstract

Neural Processes (NPs) offer a flexible, neural-network-based approach to modeling distributions over functions. They provide a computationally efficient alternative to Gaussian Processes (GPs), boasting linear complexity compared to the $O(n^3)$ cost of GPs. However, standard NPs suffer from a significant underfitting problem, often yielding "blurry" predictions that fail to accurately capture observed context points. In the paper Attentive Neural Processes, Kim et al. address this flaw by integrating attention mechanisms. This allows the model to focus on relevant data points, drastically improving accuracy, training speed, and the model's capacity to represent complex functions.

The Underfitting Problem in Neural Processes

In machine learning, modeling a distribution over functions means creating a system that can observe a few data points (a "context set") and infer all possible curves or images that could pass through them. While GPs are the gold standard for this task, their cubic computational complexity limits their scalability.

NPs were introduced to solve this scalability issue, but they introduced a new bottleneck: underfitting. Standard NPs use a simple "mean-aggregation" step to summarize all context points into a single global latent vector. This averaging process discards fine-grained, local details. As a result, 1D curve fits often fail to pass through the actual observed data points, and 2D image reconstructions (where coordinates are mapped to pixel intensities) appear blurry and lack sharp features.

Comparison of NP and Attentive NP on 1D regression and 2D image completion

Methods: Introducing Attention

To overcome the mean-aggregation bottleneck, the authors introduce Attentive Neural Processes (ANPs). ANPs improve upon the standard architecture by incorporating two types of attention mechanisms within a dual-path framework:

  1. Cross-Attention (Deterministic Path): Instead of averaging all context points equally, the model uses cross-attention. When predicting a value at a new target location, the model "attends" to the context points that are most relevant—typically those closest in the input space. This allows the model to capture fine-grained, local structure.
  2. Self-Attention: Before context points are used for prediction, they interact with each other via self-attention. This enables the model to learn richer, more complex representations of the data by modeling the relationships between observed points.
  3. Global Latent Path: ANPs retain a global latent variable (similar to the original NP) to capture the overall "style" or global uncertainty of the function, ensuring the model can still generate diverse samples.

Key Insights and Results

The researchers evaluated ANPs on synthetic 1D GP data, MNIST digits, and CelebA face images (treated as 2D spatial regression tasks). The inclusion of attention yielded several major improvements:

  • Visual Quality and Accuracy: In 1D regression, ANPs achieved significantly lower Negative Log-Likelihood (NLL) and reconstruction error than standard NPs. On image datasets like CelebA and MNIST, ANPs produced crisp, detailed images that accurately reconstructed the context pixels, whereas standard NPs produced blurry, "average" faces.
  • Attention as a "Differentiable Kernel": The authors draw a compelling parallel between attention in neural networks and kernels in GPs. Both mechanisms define "similarity" between points, but attention allows the model to learn that similarity directly from the data.
  • Faster Convergence: Surprisingly, even though attention adds more computation per training step, ANPs converge much faster than NPs in terms of total wall-clock time. The attention mechanism provides a much clearer, more direct learning signal.
  • Resolution Independence: Because ANPs model images as continuous functions mapping $(x,y)$ coordinates to colors, a model trained on low-resolution images can perform "zero-shot" super-resolution on high-resolution grids.
  • Bayesian Optimization: When utilized as a surrogate model for Bayesian Optimization, ANPs equipped with multihead attention performed nearly as well as an "Oracle" GP that had access to the true underlying parameters.

Limitations and Future Directions

While ANPs represent a massive leap forward for Neural Processes, they come with trade-offs. The primary limitation is computational cost at inference. While training is faster overall, the computational complexity of ANPs is $O(n(n+m))$ (where $n$ is the number of context points and $m$ is the number of target points), compared to the standard NP's $O(n+m)$. For extremely large context sets, this quadratic scaling could become a bottleneck.

Additionally, while ANPs behave like stochastic processes, they do not strictly satisfy the formal mathematical requirement of "consistency" (the Kolmogorov Extension Theorem) that GPs do.

Future work suggested by the authors includes applying ANPs to non-spatial data, such as text (e.g., filling in missing words), and exploring more sophisticated attention structures within the decoder to further expand the family of functions these models can represent.

Summary updated

BibTeX
@inproceedings{kim2019attentive,
  author = {Hyunjik Kim and Andriy Mnih and Jonathan Schwarz and Marta Garnelo and S. M. Ali Eslami and Dan Rosenbaum and Oriol Vinyals and Yee Whye Teh},
  title = {{Attentive Neural Processes}},
  booktitle = {International Conference on Learning Representations},
  year = {2019},
  url = {https://openreview.net/forum?id=UEEgixtcLR},
}
Figure