Skip to main content

Parametric modeling in JAX

Project description

Parax

Parax is a library for parametric modeling in JAX. Features include:

  • Derived/constrained parameters with metadata
  • Computed PyTrees and callable parameterizations
  • Abstract interfaces for fixed, bounded, and probabilistic PyTrees
  • Associated filtering and tree manipulation tools

The above makes Parax great for:

  • Parameterizations in machine learning
  • Bounded optimization in scientific modeling
  • Bayesian inference in probabilistic modeling

Examples for each of these are available in the documentation.

Note that Parax is not a framework, and is designed to be both extendable and interoperable 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.Param(1.0, metadata={'hello', 'world'})
p2 = prx.Constrained(8.0, prx.Interval(0.0, 10.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(3.0, jnp.log)}}
wrapped = prx.Computed(pytree, jnp.exp)

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, while prx.Derived is an array-like prx.AbstractVariable.

Related

The library's design was inspired by several others that deserve mention, including Flax, paramax, and PyTorch.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parax-0.5.12.tar.gz (454.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parax-0.5.12-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file parax-0.5.12.tar.gz.

File metadata

  • Download URL: parax-0.5.12.tar.gz
  • Upload date:
  • Size: 454.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for parax-0.5.12.tar.gz
Algorithm Hash digest
SHA256 718bfe4df0b5ca6e06022787862c295e43185a1751d93f717975bbd9c6e635c1
MD5 5b14df29f2b999ba750b561b18bb5c21
BLAKE2b-256 6e9a30ad78ed0432dfe1c9dbcfd638ddfd89e1759da868f0a1056382a547fd41

See more details on using hashes here.

Provenance

The following attestation bundles were made for parax-0.5.12.tar.gz:

Publisher: publish.yml on gvcallen/parax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parax-0.5.12-py3-none-any.whl.

File metadata

  • Download URL: parax-0.5.12-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for parax-0.5.12-py3-none-any.whl
Algorithm Hash digest
SHA256 bf0a739d752e9dfbe8e11b551c9ca99e7c272fad77ab1eafe97aa481379c7390
MD5 d4f19c4fc1f5d3d9b516d97da48196a3
BLAKE2b-256 11c842488b55583ec8cd425664deab25ca37166b90eaa4547a9fa3fd7e7d7f99

See more details on using hashes here.

Provenance

The following attestation bundles were made for parax-0.5.12-py3-none-any.whl:

Publisher: publish.yml on gvcallen/parax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page