Parametric modeling in JAX
Project description
Parax
Parax is a library for parametric modeling in JAX. Features include:
- Parameters with metadata
- Computed PyTrees and callable parameterizations
- Derived, constrained, fixed, and random variables
- Arbitrary nesting of the above
- Abstract interfaces and associated tree manipulation tools
This makes Parax great for:
- Parameterizations for machine learning
- Bounded optimization for scientific modeling
- Bayesian inference for probabilistic modeling
- Combinations of these
Note that Parax is not a framework, though it can be used to make one. Rather, it is focused extendability and interoperability with other JAX libraries (especially Equinox).
Installation
Parax can be installed using pip:
pip install parax
For some constraints and probabilistic features, you may need this distreqx branch:
pip install git+https://github.com/gvcallen/distreqx.git
Documentation
Documentation is available here.
Quick example
Parax provides array-like variables that hold metadata and can be parameterized/constrained:
import parax as prx
import jax.numpy as jnp
p1 = prx.Tagged(1.0, metadata={'hello', 'world'})
p2 = prx.Constrained(prx.constraints.Interval(0.0, 10.0), value=8.0)
p2.raw_value, p2.bounds
# Array(1.3862944), (Array(0.0), Array(10.0))
jnp.sin(p1) + (2 * p2)
# Array(16.84147)
You can also apply arbitrary computations to PyTrees and parameters using unwrapping:
pytree = {'a': 1.0, 'b': {'x': 2.0, 'y': prx.Derived(jnp.log, 3.0)}}
wrapped = prx.Computed(jnp.exp, pytree)
prx.unwrap(wrapped)
# {'a': Array(2.7182817),
# 'b': {'x': Array(7.389056),
# 'y': Array(3.0)}}
In the above example, prx.Computed operates on the whole PyTree's array-like nodes, while prx.Derived is an array-like prx.AbstractVariable.
Next steps
Several tutorials are available in the documentation, for example:
- Regular optimization (Optimistix)
- Bounded optimization (JAXopt)
- Bayesian inference (BlackJAX)
Related
The library's design was inspired by several others that deserve mention, including Flax, paramax, and PyTorch.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file parax-0.6.2.tar.gz.
File metadata
- Download URL: parax-0.6.2.tar.gz
- Upload date:
- Size: 460.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
765ae94e788419ca26bc5d3fe7ce7ddff57e8f3d39f4b4326c40737ab161db72
|
|
| MD5 |
9020a7a898a819aa8c1dcc4814c028ab
|
|
| BLAKE2b-256 |
c6aec83e0ce825f349c3636e58a7f60609fa205224f76499d64e7cd78fb40508
|
Provenance
The following attestation bundles were made for parax-0.6.2.tar.gz:
Publisher:
publish.yml on gvcallen/parax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
parax-0.6.2.tar.gz -
Subject digest:
765ae94e788419ca26bc5d3fe7ce7ddff57e8f3d39f4b4326c40737ab161db72 - Sigstore transparency entry: 1442853070
- Sigstore integration time:
-
Permalink:
gvcallen/parax@9a3fff7d47a6df0fa035bb194d5e00237d935f7c -
Branch / Tag:
refs/tags/v0.6.2 - Owner: https://github.com/gvcallen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9a3fff7d47a6df0fa035bb194d5e00237d935f7c -
Trigger Event:
push
-
Statement type:
File details
Details for the file parax-0.6.2-py3-none-any.whl.
File metadata
- Download URL: parax-0.6.2-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4878db8c5e1008c65b1fd999ea7f2bfaeaf27dd811365f026008a6b875849c1
|
|
| MD5 |
6f77938f93f2869b58a237a889a091dd
|
|
| BLAKE2b-256 |
bb13fc9eebcd934f5cba178676ee65c8476b5cfae1a64bb03fd5e95e111b3f66
|
Provenance
The following attestation bundles were made for parax-0.6.2-py3-none-any.whl:
Publisher:
publish.yml on gvcallen/parax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
parax-0.6.2-py3-none-any.whl -
Subject digest:
f4878db8c5e1008c65b1fd999ea7f2bfaeaf27dd811365f026008a6b875849c1 - Sigstore transparency entry: 1442853159
- Sigstore integration time:
-
Permalink:
gvcallen/parax@9a3fff7d47a6df0fa035bb194d5e00237d935f7c -
Branch / Tag:
refs/tags/v0.6.2 - Owner: https://github.com/gvcallen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9a3fff7d47a6df0fa035bb194d5e00237d935f7c -
Trigger Event:
push
-
Statement type: