Utility functions for JaxGaussianProcesses
Project description
This project has now been incorporated into GPJax.
JaxUtils
JaxUtils
provides utility functions for the JaxGaussianProcesses
ecosystem.
Contents
PyTree
Overview
jaxutils.PyTree
is a mixin class for registering a python class as a JAX PyTree. You would define your Python class as follows.
class MyClass(jaxutils.PyTree):
...
Example
import jaxutils
from jaxtyping import Float, Array
class Line(jaxutils.PyTree):
def __init__(self, gradient: Float[Array, "1"], intercept: Float[Array, "1"]) -> None
self.gradient = gradient
self.intercept = intercept
def y(self, x: Float[Array, "N"]) -> Float[Array, "N"]
return x * self.gradient + self.intercept
Dataset
Overview
jaxutils.Dataset
is a datset abstraction. In future, we wish to extend this to a heterotopic and isotopic data abstraction.
Example
import jaxutils
import jax.numpy as jnp
# Inputs
X = jnp.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
# Outputs
y = jnp.array([[7.0], [8.0], [9.0]])
# Datset
D = jaxutils.Dataset(X=X, y=y)
print(f'The number of datapoints is {D.n}')
print(f'The input dimension is {D.in_dim}')
print(f'The output dimension is {D.out_dim}')
print(f'The input data is {D.X}')
print(f'The output data is {D.y}')
print(f'The data is supervised {D.is_supervised()}')
print(f'The data is unsupervised {D.is_unsupervised()}')
The number of datapoints is 3
The input dimension is 2
The output dimension is 1
The input data is [[1. 2.]
[3. 4.]
[5. 6.]]
The output data is [[7.]
[8.]
[9.]]
The data is supervised True
The data is unsupervised False
You can also add dataset together to concatenate them.
# New inputs
X_new = jnp.array([[1.5, 2.5], [3.5, 4.5], [5.5, 6.5]])
# New outputs
y_new = jnp.array([[7.0], [8.0], [9.0]])
# New dataset
D_new = jaxutils.Dataset(X=X_new, y=y_new)
# Concatenate the two datasets
D = D + D_new
print(f'The number of datapoints is {D.n}')
print(f'The input dimension is {D.in_dim}')
print(f'The output dimension is {D.out_dim}')
print(f'The input data is {D.X}')
print(f'The output data is {D.y}')
print(f'The data is supervised {D.is_supervised()}')
print(f'The data is unsupervised {D.is_unsupervised()}')
The number of datapoints is 6
The input dimension is 2
The output dimension is 1
The input data is [[1. 2. ]
[3. 4. ]
[5. 6. ]
[1.5 2.5]
[3.5 4.5]
[5.5 6.5]]
The output data is [[7.]
[8.]
[9.]
[7.]
[8.]
[9.]]
The data is supervised True
The data is unsupervised False
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jaxutils-nightly-0.0.8.dev20240119.tar.gz
.
File metadata
- Download URL: jaxutils-nightly-0.0.8.dev20240119.tar.gz
- Upload date:
- Size: 30.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e749059d2e99df4e589ed8e874ab59919ff76e35ddc2d493c3a3bee09de4dd82 |
|
MD5 | 1d5b0cb12db0ce2b474306df84e4d839 |
|
BLAKE2b-256 | f9850c40be4ea8b2d2db1bd7b77d30abf6978e12a10182581f3fe2d840069d78 |
File details
Details for the file jaxutils_nightly-0.0.8.dev20240119-py3-none-any.whl
.
File metadata
- Download URL: jaxutils_nightly-0.0.8.dev20240119-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c3f6fb3af251f6f46f8cc8dc9c943e76d3e17c22ef9c42a53565f109579b78a |
|
MD5 | 2c926d7cd16e1996197bc95fd99ea221 |
|
BLAKE2b-256 | 5eb1b06f6b289f5b2324afdb7540c0d086c891f86a0996ae7d438000a7c505b6 |