← Explainer Library

Interactive Explainer

Neural Processes, Live

A neural net that learns "priors over functions" the way a Gaussian process does — but amortised. Click context points; a Conditional Neural Process predicts the rest with uncertainty that bows out where data is missing. Compare to a real GP fit on the same context.

Prelude

What problem does an NP solve?

You have a small context set of $(x, y)$ pairs and you want to predict $y$ at new $x$ values, with uncertainty. A Gaussian process does this with a kernel. A neural process replaces the kernel with a learned encoder/decoder, then amortises inference: at test time it's a single forward pass — no optimisation, no kernel-matrix inversion.

The slogan. An NP is a meta-learned surrogate for a GP. You pay a one-time training cost over many functions; thereafter every prediction is one forward pass.
Step 1

Architecture: encoder → aggregate → decoder

The Conditional Neural Process (Garnelo et al., 2018):

$h$ is a small MLP that turns each context pair $(x_i, y_i)$ into a representation $r_i$. The aggregator is a permutation-invariant pooling (mean) into a single representation $r$. The decoder $g$ maps $(x_*, r)$ to the predicted mean and variance at any query $x_*$.

The CNP pipeline. Mean-pooling makes the model permutation-invariant in the context set.
Step 2

Try it: click points, see the posterior

Click anywhere on the canvas to add a context point. Right-click (or shift-click) to remove. The model is pre-trained on a family of smooth functions; it's not training as you click — it just runs a single forward pass per point. The GP fit on the same context is shown for comparison.

|context| = 0
Neural Process posterior (mean ± 2σ)
GP posterior on same context (RBF)
What to watch for. With 0 context points, the NP returns the prior mean of its training family (often roughly zero) with a wide band; the GP returns its prior. Add a few points and both shrink the band locally. The NP's band has a slightly different shape away from the data — the NP has learned what kinds of functions are likely (smoothness, periodicity) from the family it was trained on; the GP only knows its kernel hyperparameters.
Step 2½

The training objective — meta-learning, formally

NPs are trained by meta-learning: simulate many small datasets and ask the NP to predict held-out points within each. For one task with context $\mathcal{C} = \{(x_i, y_i)\}$ and target $\mathcal{T} = \{(x_j, y_j)\}$ the deterministic CNP minimises

where $\mu, \sigma^2$ come from the decoder conditioned on the aggregated representation $r_\mathcal{C}$. The expectation is over many sampled $(\mathcal{C}, \mathcal{T})$ pairs from a task distribution.

The Latent NP introduces a global latent $z$ and uses an ELBO:

$q(z|\mathcal{C} \cup \mathcal{T})$ is the variational posterior (encoder over context + target); $p(z|\mathcal{C})$ is the prior (encoder over context only). Sampling $z$ gives function-consistent samples across queries — drawing whole functions, like a GP. The CNP is the degenerate case where $z$ collapses to a point estimate.

Step 3

The variants and what each adds

Step 4

When to reach for an NP vs a GP

Final takeaway. Neural processes are GPs amortised. If you have many small related tasks and want fast predictions with calibrated uncertainty, they are the right tool. If you have a single big task and want crisp probabilistic semantics, a GP (or deep kernel learning) still wins.
Step 5

Failure modes and how to spot them

Step 6

Reading list