Skip to main content

Composable expressions in JAX + Equinox

Project description

eqxpress is a lightweight library for composing expressions over input-output PyTree spaces. It allows you to build deferred computation graphs and abstract syntax trees (ASTs) using standard Python operators.

Since eqxpress is built natively on Equinox, each new instance of AbstractExpression is a new PyTree, and therefore any PyTree leaves (weights, arrays, parameters) are propagated throughout nested operations.

eqxpress
Author Gary Allen
Homepage github.com/eqxpress/eqxpress
Docs gvcallen.github.io/eqxpress

Installation

eqxpress can be installed via pip:

pip install eqxpress

Example: Composing Modules

If you have an existing hierarchy of Equinox modules with matching input/output signatures, simply inheriting from AbstractExpression grants them instant, declarative composition.

A common use case is building composite loss functions for optimization:

import jax.numpy as jnp
from eqxpress import AbstractExpression

class MSELoss(AbstractExpression):
    def __call__(self, y_true, y_pred):
        return jnp.mean((y_true - y_pred) ** 2)

class L2Regularization(AbstractExpression):
    def __call__(self, y_true, y_pred):
        return jnp.sum(y_pred ** 2)

# Build a deferred computation graph
total_loss = MSELoss() + 0.01 * L2Regularization()

# Evaluate the combined mapping
y_t = jnp.array([1.0, 0.0])
y_p = jnp.array([0.9, 0.1])

loss_value = total_loss(y_true=y_t, y_pred=y_p)

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

eqxpress-0.0.4.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

eqxpress-0.0.4-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file eqxpress-0.0.4.tar.gz.

File metadata

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

File hashes

Hashes for eqxpress-0.0.4.tar.gz
Algorithm Hash digest
SHA256 865f40e72f9c9b085d5018f1fa314c12e7c21923561ef5aca61f8628147f7eca
MD5 bea656c40768013d1ff993dcf9d21be9
BLAKE2b-256 be02244e29c7dfc657a2be5d6f6f69d2afdb91ca68b6370ef2eb8cc3cc6dfb2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for eqxpress-0.0.4.tar.gz:

Publisher: publish.yml on gvcallen/eqxpress

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

File details

Details for the file eqxpress-0.0.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for eqxpress-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 81270bc9a9e32be2ea91f77a8b5cbcc8ebdefab33f728addaa5dbd4d34be9510
MD5 90a5c281bb165919d32c212eaabfb709
BLAKE2b-256 553f30f049bbb56fb7d03875bb51d7d67df3ff9aed0803c01fc33e9c65093331

See more details on using hashes here.

Provenance

The following attestation bundles were made for eqxpress-0.0.4-py3-none-any.whl:

Publisher: publish.yml on gvcallen/eqxpress

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