Neural processes: learning to predict a whole function from a few points
A neural process learns, across many related curves, how to predict a new curve from a handful of observed points, with no refitting. Conditional, latent and attentive versions, what each fixes, and how to evaluate them on unseen tasks.
What runs in CodeSplash
- UNC016Conditional neural process (CNP) Needs a data type CodeSplash doesn't load yet
- UNC017Latent neural process (NP) Needs a data type CodeSplash doesn't load yet
- UNC018Attentive neural process (ANP) Needs a data type CodeSplash doesn't load yet
You will be able to
- Explain amortization across tasks and why the context set must be order-free
- Contrast the conditional neural process with the latent version's coherent samples
- Explain the bottleneck that attentive neural processes remove
- Design an evaluation that splits by task, not by point
A GP that learned its prior from data
ReadA GP predicts a curve from a few observed points using a kernel you choose. A neural processNeural processA network trained across many related curves to predict a new curve from a few observed points in one pass, with uncertainty. learns that skill instead, from many example curves of the same kind: daily temperature profiles, growth curves, sensor traces.
Training shows it thousands of tasks, each split into context points (seen) and target points (to predict). At use, you hand it a new context set of any size and it predicts the rest of the curve in one pass, with no refitting. That is amortization: the cost of inference was paid up front, across tasks.
Conditional neural process
ReadThe CNP encodes each context pair and averages: . Averaging makes the summary ignore the order of the context points, as it should. A decoder then predicts each target independently: .
In the reference's small example, two context points give a two-number summary and target means of −0.393 and 0.407, each with SD 0.836. Because targets are predicted independently, drawing from a CNP gives a jagged set of points, not a plausible curve.
Latent neural process
ReadThe latent NP adds a random variable shared by all targets. One draw of gives one whole, coherent function; another draw gives another. It's trained with a variational objective,
where the posterior sees the targets only during training. At use, sample from and reuse it for every target of that function. Watch for a latent the decoder ignores (the KL falls to zero) and for target labels leaking into at evaluation.
One summary for every target
PredictPredict first
A CNP sees forty context points, three of them tracing a sharp bump near one target location. What does a single averaged summary do to the prediction at that location?
Reveal
It blurs the bump. One mean vector serves every target, so local detail is averaged away and CNPs underfit dense context. Attentive neural processes let each target look up the context points relevant to it.
Attentive neural process
ReadThe ANP keeps a latent path for coherence and adds cross-attention: each target query compares itself with context keys and reads a weighted mix of values, . Nearby, relevant context points get the most weight. In the reference's example, one target puts weight 0.480 on its first context point.
Attention costs one score per context–target pair, and good interpolation doesn't promise good extrapolation. Attention weights are a retrieval diagnostic, not proof of what caused a prediction.
Evaluating by task
ReadThe unit of a neural process is the task, so split by task: whole curves in training, other whole curves in evaluation. Holding out points from training curves only tests memory.
Then plot target log likelihood against context size and distance from the nearest context point, separate interpolation from extrapolation, check that shuffling the context leaves predictions unchanged, and compare CNP, NP and ANP on identical splits and context budgets.
Where each idea stands in CodeSplash
Read| Entry | In CodeSplash |
|---|---|
| Conditional neural process (UNC016) | Needs a data type CodeSplash doesn't load yet: a collection of curves treated as tasks |
| Latent neural process (UNC017) | Needs a data type CodeSplash doesn't load yet |
| Attentive neural process (UNC018) | Needs a data type CodeSplash doesn't load yet |
For one curve at a time, a Gaussian process in Predict predicts from observed points with a kernel you choose.
Reference · UNC016 · Needs a data type CodeSplash doesn't load yetConditional neural process (CNP)Predict a target function’s outputs after observing a variable-size set of context input/output pairs, without refitting weights for every new context set. Reference · UNC017 · Needs a data type CodeSplash doesn't load yetLatent neural process (NP)Add a shared random latent variable to a context-conditioned neural predictor so sampled outputs can vary coherently across target locations. Reference · UNC018 · Needs a data type CodeSplash doesn't load yetAttentive neural process (ANP)Use attention to preserve target-specific information from a context set while retaining a global latent path for coherent uncertainty.Check your understanding
CheckpointCheck yourself
What does a conditional neural process do with a new context set?
Show the answer
Answer: b
Training across many tasks taught it how to condition. New contexts only need a forward pass.
Check yourself
Why do samples from a CNP look jagged rather than like smooth curves?
Show the answer
Answer: a
The factorized likelihood gives good pointwise predictions but no joint structure. A shared latent fixes that.
Check yourself
What does the latent NP's shared variable z give you?
Show the answer
Answer: b
Reusing one draw of z for every target ties the predictions together. The context encoder remains an approximation.
Check yourself
In evaluation, your latent NP samples z from a posterior that saw the target points. What's wrong?
Show the answer
Answer: b
The posterior with targets is a training device. At evaluation, condition on the context alone.
Check yourself
What problem do attentive neural processes address?
Show the answer
Answer: b
Cross-attention lets each target read the context points most relevant to it.
Check yourself
An ANP puts most attention on one context point for a target. What can you conclude?
Show the answer
Answer: a
Attention weights show retrieval. The decoder and the latent path also shape the output.
Check yourself
How should you split data to evaluate a neural process?
Show the answer
Answer: b
Neural processes promise transfer to new tasks. Point-level holdouts from training curves only test memory.
What comes next
RecapThe next unit moves from uncertainty about numbers to structure among labels: predicting a whole sequence of labels at once with conditional random fields.
Concepts in this lesson