Conditional Neural Processes

Marta Garnelo, Dan Rosenbaum, Christopher Maddison, Tiago Ramalho, David Saxton, Murray Shanahan, Yee Whye Teh, Danilo Jimenez Rezende, S. M. Ali Eslami

Deep neural networks are powerful function approximators, but they are notoriously "data hungry" and typically require training from scratch for every new task. Conversely, Bayesian methods like Gaussian Processes (GPs) excel at "few-shot" learning—using prior knowledge to infer the shape of a function from just a few points. However, GPs suffer from poor scalability, with computational costs growing cubically ($O(n^3)$) as data increases, and they require manually designed priors (kernels) that limit expressivity.

Conditional Neural Processes (CNPs) bridge this gap. They combine the data efficiency and probabilistic reasoning of Bayesian methods with the scalability and flexibility of deep learning. By learning to represent entire families of functions, CNPs can make accurate probabilistic predictions from just a few observations while maintaining linear computational complexity.

The CNP Architecture

The CNP model is designed to be permutation invariant, meaning the order of the input observations does not affect the final prediction. The architecture follows a simple three-step pipeline:

CNP Architecture Comparison
  1. Encoder ($h$): Each observation (an input-output pair $\{x_i, y_i\}$) is passed through a neural network to produce an individual representation $r_i$.
  2. Aggregator ($\oplus$): All individual representations are combined into a single, fixed-size vector $r$ using a commutative operation, such as a mean. This vector acts as a "summary" of the current context.
  3. Decoder ($g$): To predict the value at a new target location $x_*$, the decoder takes both the summary vector $r$ and the target $x_*$ to output a probability distribution (typically a mean and variance) for the predicted value $y_*$.

Because the aggregator produces a fixed-size representation, the computational complexity is $O(n+m)$ (where $n$ is the number of observations and $m$ is the number of predictions). This is a massive improvement over the $O(n^3)$ scaling of GPs. The model is trained via "meta-learning": it is shown various subsets of data from different functions and tasked with predicting the remaining points, maximizing the likelihood of the true values.

Key Results and Insights

CNPs were evaluated across diverse tasks, including 1D regression, image completion (MNIST and CelebA), and one-shot classification (Omniglot).

Learning the Prior: Unlike GPs, which require human-engineered mathematical kernels, CNPs learn the "statistics of the domain" directly from the training data. They essentially learn how to learn within a specific field.

Uncertainty Awareness in Regression: CNPs do not just output a single best guess; they provide a variance. The model correctly identifies that uncertainty is highest in regions far from observations. In 1D regression tasks, CNPs successfully modeled functions with "switching" kernels—a notoriously difficult task for traditional GPs that assume a consistent global correlation structure.

1D Regression with CNPs vs GPs

Images as Functions: By treating images as functions mapping 2D coordinates to pixel intensities, CNPs can perform tasks like super-resolution or predict missing pixels. On the CelebA dataset, the model could produce a recognizable face from less than 10% of the pixels. While the outputs were somewhat blurry (representing an average of possible faces), the uncertainty maps accurately highlighted the edges of facial features.

Classification: On the Omniglot one-shot benchmark, CNPs achieved 95.3% accuracy on 5-way 1-shot classification. While slightly lower than specialized state-of-the-art models, CNPs offer a significantly faster and simpler architecture.

Limitations and Future Work

The primary limitation of the basic CNP is that it produces factored outputs. It predicts the probability of each target point independently and therefore cannot produce "coherent samples." For instance, if shown half a face, it might predict the average of all possible matching faces rather than generating one specific, sharp face.

To address this, the authors suggest integrating a Latent Variable model (similar to a Variational Autoencoder) to allow for coherent sampling, paving the way for scaling these models to higher-dimensional data and complex temporal sequences.

Summary updated

BibTeX
@inproceedings{garnelo2018conditional,
  author = {Marta Garnelo and Dan Rosenbaum and Christopher Maddison and Tiago Ramalho and David Saxton and Murray Shanahan and Yee Whye Teh and Danilo Jimenez Rezende and S. M. Ali Eslami},
  title = {{Conditional Neural Processes}},
  booktitle = {International Conference on Machine Learning},
  year = {2018},
  url = {https://openreview.net/forum?id=rJVq4h-dWS},
}
Figure