Skip to main content

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
  • Probabilistic modeling and Bayesian inference
  • Deep, nested PyTrees
  • Combinations of the above

Note that Parax is not a framework, though it can be used to make one. Rather, it is focused on 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:

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.7.2.tar.gz (464.8 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.7.2-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for parax-0.7.2.tar.gz
Algorithm Hash digest
SHA256 fbfc74b5ef5bfc86bd0138498d9b18c471215ab39c7a60547fc869c19d44c055
MD5 05ed08425aab184d87dab138e8253da6
BLAKE2b-256 fbfb761f53b6ec7addcbdb8d55414fe8e1e8f31485f87ff6449c4bad268bebbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for parax-0.7.2.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.7.2-py3-none-any.whl.

File metadata

  • Download URL: parax-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 39.0 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.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 84db9f3561636d0ebd29a6d3c4a0f4adb772da3fb324a8c31be7c151a3b38e80
MD5 c178adeb06c3c1d4bb8af2dafe003b56
BLAKE2b-256 7e675238bae70ff28b5cb3b2e375c3f5f87fe465c4fd75c57e54b75808bd1dba

See more details on using hashes here.

Provenance

The following attestation bundles were made for parax-0.7.2-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