Ramsey
Probabilistic deep learning using JAX
About
Ramsey is a library for probabilistic deep learning using JAX, Flax and NumPyro. Its scope covers
- neural processes (vanilla, attentive, Markovian, convolutional, ...),
- neural Laplace and Fourier operator models,
- etc.
Example usage
You can, for instance, construct a simple neural process like this:
from flax import nnx
from ramsey import NP
from ramsey.nn import MLP # just a flax.nnx module
def get_neural_process(in_features, out_features):
dim = 128
np = NP(
latent_encoder=(
MLP(in_features, [dim, dim], rngs=nnx.Rngs(0)),
MLP(dim, [dim, dim * 2], rngs=nnx.Rngs(1))
),
decoder=MLP(in_features, [dim, dim, out_features * 2], rngs=nnx.Rngs(2))
)
return np
neural_process = get_neural_process(1, 1)
The neural process above takes a decoder and a set of two latent encoders as arguments. All of these are typically flax.nnx MLPs, but
Ramsey is flexible enough that you can change them, for instance, to CNNs or RNNs.
Ramsey provides a unified interface where each method implements (at least) __call__ and loss
functions to transform a set of inputs and compute a training loss, respectively:
from jax import random as jr
from ramsey.data import sample_from_sine_function
data = sample_from_sine_function(jr.key(0))
x_context, y_context = data.x[:, :20, :], data.y[:, :20, :]
x_target, y_target = data.x, data.y
# make a prediction
pred = neural_process(
x_context=x_context,
y_context=y_context,
x_target=x_target,
)
# compute the loss
loss = neural_process.loss(
x_context=x_context,
y_context=y_context,
x_target=x_target,
y_target=y_target
)
Installation
To install from PyPI, call:
pip install ramsey
To install the latest GitHub , just call the following on the command line:
pip install git+https://github.com/ramsey-devs/ramsey@<RELEASE>
See also the installation instructions for JAX, if you plan to use Ramsey on GPU/TPU.
Contributing
Contributions in the form of pull requests are more than welcome. A good way to start is to check out issues labelled "good first issue".
In order to contribute:
- Clone Ramsey and install
uvfrom here, - create a new branch locally
git checkout -b feature/my-new-featureorgit checkout -b issue/fixes-bug, - install all dependencies via
uv sync --all-extras, - implement your contribution and ideally a test case,
- test it by calling
make format,make lintsandmake testson the (Unix) command line, - submit a PR 🙂
Why Ramsey
Just as the names of other probabilistic languages are inspired by researchers in the field (e.g., Stan, Edward, Turing), Ramsey takes its name from one of my favourite philosophers/mathematicians, Frank Ramsey.
Metadata
Release files for ramsey 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ramsey-0.3.0.tar.gz | 509.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ramsey-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 536.6 kB
Release files / ramsey-0.3.0.tar.gz
| Download URL | ramsey-0.3.0.tar.gz |
|---|---|
| Size | 509.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5bb024c60498ec397fa960fd73f9afa3f4d34c5030087fd1f4c71b343dedfc8
|
|
BLAKE2b-256 checksum How to use checksums |
7071d697d75e83f2c9fd506c2f3c812e765d0db43cd5798240bf3e8534e74862
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / ramsey-0.3.0-py3-none-any.whl
| Download URL | ramsey-0.3.0-py3-none-any.whl |
|---|---|
| Size | 27.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d875813c5339be37f010907d822b6b6439012e0ddfee342353edad60d8d436ac
|
|
BLAKE2b-256 checksum How to use checksums |
03f3f58d4e5a0935a37249d5371b9a09c96a92b1f63d823f9e809696ed65cb91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for ramsey 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.