All models

TNP

Transformer Neural Processes cast uncertainty-aware meta learning as autoregressive sequence modeling.

273 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (42 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
222.1K
Operations
273
Framework
PyTorch
Recurrent
No
Published
ICML 2022
Cited by
19 (as of 18 October 2026)
Authors
Tung Nguyen, Aditya Grover
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m3020
Graph hash
ac5682e7006ba5b65c590c6406baad9ebc28d2503ecfce496fb6220adcf7bd2e
Skeleton hash
769c33a2a7236d890539024bbda5f7e898259fbe482b54040879ca3b09bfb3fd
Architecture hash
7068f894a20dd87bf065034b9d92858d8bdcf45373a1f52c6c2e28cea8703783
Diagram SHA-256
3dcff6b58648daa7f73b7dd8dd077bab3f0d41205a8951a790c9fe0c571b3ce8
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

Transformer Neural Processes (TNPs) are a member of the Neural Processes family that casts uncertainty-aware meta learning as a sequence modeling problem. Neural Processes define distributions over functions and can estimate uncertainty in their predictions, but NPs and their variants suffer from underfitting and often have intractable likelihoods. TNPs are learned with an autoregressive likelihood-based objective and instantiated with a transformer-based architecture.

The learning objective is to autoregressively maximize the conditional log-likelihood of the target points conditioned on the context points. This removes the need for latent variables and any variational approximations. Vanilla transformers cannot be used directly, because they lack invariance to the conditioned tokens and are not equivariant to the ordering of the target points. Each input x and its label y are therefore concatenated to form a single token, which allows the positional encodings to be removed while still treating them as a pair. A padding and masking scheme for the context and target points preserves the autoregressive structure. The diagonal variant TNP-D treats its decoding distribution as a multivariate normal with a diagonal covariance matrix. The non-diagonal variant TNP-ND parameterizes the decoding distribution as a multivariate normal with a non-diagonal covariance matrix. Among the three variants, TNP-A achieves the best likelihood due to its autoregressive decoder, followed by TNP-ND and finally TNP-D.

TNPs achieve state-of-the-art performance on various benchmark problems, outperforming all previous NP variants on meta regression, image completion, contextual multi-armed bandits, and Bayesian optimization. Parameter counts, training time and prediction time are comparable to the baselines, except that TNP-A incurs a higher prediction time because of its autoregressive nature. In 1-D regression the training functions are drawn from a Gaussian Process prior with an RBF kernel. For that task the paper uses model dimension 64, 4 embedding layers, feed-forward dimension 128 and 4 attention heads. The transformer stack has 6 layers.

Key idea. TNPs' key contribution is an alternative framing of uncertainty-aware meta learning via sequence modeling, optimizing an autoregressive objective with a transformer backbone. Rather than only adding attention to a Neural Process as earlier work did, replacing the entire architecture stack drastically improves performance across benchmark tasks.

  • transformer neural process
  • transformer neural processes
  • tnp
  • tnp-d
  • tnp-a
  • tnp-nd
  • neural process
  • neural processes
  • uncertainty-aware meta learning
  • meta learning
  • sequence modeling
  • gaussian process regression
  • image completion
  • contextual bandits
  • bayesian optimization
  • diagonal transformer neural process

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{nguyen2023transformerneuralprocessesuncertaintyaware,
      title={Transformer Neural Processes: Uncertainty-Aware Meta Learning Via Sequence Modeling}, 
      author={Tung Nguyen and Aditya Grover},
      year={2023},
      eprint={2207.04179},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2207.04179}, 
}