Skip to main content

Neural Processes

CI Coverage Status Latest Docs Code style: black

A framework for composing Neural Processes in Python.

Installation

pip install neuralprocesses tensorflow tensorflow-probability  # For use with TensorFlow
pip install neuralprocesses torch                              # For use with PyTorch

If something is not working or unclear, please feel free to open an issue.

Documentation

See here.

TL;DR! Just Get me Started!

Here you go:

import torch

import neuralprocesses.torch as nps

# Construct a ConvCNP.
convcnp = nps.construct_convgnp(dim_x=1, dim_y=2, likelihood="het")

# Construct optimiser.
opt = torch.optim.Adam(convcnp.parameters(), 1e-3)

# Training: optimise the model for 32 batches.
for _ in range(32):
    # Sample a batch of new context and target sets. Replace this with your data. The
    # shapes are `(batch_size, dimensionality, num_data)`.
    xc = torch.randn(16, 1, 10)  # Context inputs
    yc = torch.randn(16, 2, 10)  # Context outputs
    xt = torch.randn(16, 1, 15)  # Target inputs
    yt = torch.randn(16, 2, 15)  # Target output

    # Compute the loss and update the model parameters.
    loss = -torch.mean(nps.loglik(convcnp, xc, yc, xt, yt, normalise=True))
    opt.zero_grad(set_to_none=True)
    loss.backward()
    opt.step()

# Testing: make some predictions.
mean, var, noiseless_samples, noisy_samples = nps.predict(
    convcnp,
    torch.randn(16, 1, 10),  # Context inputs
    torch.randn(16, 2, 10),  # Context outputs
    torch.randn(16, 1, 15),  # Target inputs
)

Metadata

Release files for NeuralProcesses 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for NeuralProcesses 0.2.7
File Size Uploaded
neuralprocesses-0.2.7.tar.gz 72.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for NeuralProcesses 0.2.7
File Interpreter ABI Platform
neuralprocesses-0.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 182.9 kB

Release files / neuralprocesses-0.2.7.tar.gz

Download URL neuralprocesses-0.2.7.tar.gz
Size 72.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1eaa1f41cb6e6c42935714be71d2f453f72682c3fb9cc7b1aecf58d67dd8b0eb
BLAKE2b-256 checksum
How to use checksums
4c72310b21cb06e37944df32803606678dd7376db00d0b8189e2f5bc6150d510
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / neuralprocesses-0.2.7-py3-none-any.whl

Download URL neuralprocesses-0.2.7-py3-none-any.whl
Size 110.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1434ec42600e50812b4c935e416c27723e27b40b7f4ca3e7b5102f3f07cef946
BLAKE2b-256 checksum
How to use checksums
ce09d86315d1cd7db6647541a7d2d2cd54d0c37110b3d2e8483dc88336dede9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.2.7 This release

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.14

1 release file

0.1.13

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page