Skip to main content

FlowJAX

Distributions, bijections and normalizing flows using Equinox and JAX

  • Includes a wide range of distributions and bijections.
  • Distributions and bijections are PyTrees, registered through Equinox modules, making them compatible with JAX transformations.
  • Includes many state of the art normalizing flow models.
  • First class support for conditional distributions and density estimation.

Documentation

Available here.

Short example

As an example we will create and train a normalizing flow model to toy data in just a few lines of code:

from flowjax.flows import block_neural_autoregressive_flow
from flowjax.train import fit_to_data
from flowjax.distributions import Normal
import jax.random as jr
import jax.numpy as jnp

data_key, flow_key, train_key, sample_key = jr.split(jr.key(0), 4)

x = jr.uniform(data_key, (5000, 2))  # Toy data

flow = block_neural_autoregressive_flow(
    key=flow_key,
    base_dist=Normal(jnp.zeros(x.shape[1])),
)

flow, losses = fit_to_data(
    key=train_key,
    dist=flow,
    data=x,
    learning_rate=5e-3,
    max_epochs=200,
    )

# We can now evaluate the log-probability of arbitrary points
log_probs = flow.log_prob(x)

# And sample the distribution
samples = flow.sample(sample_key, (1000, ))

The package currently includes:

  • Many simple bijections and distributions, implemented as Equinox modules.
  • coupling_flow (Dinh et al., 2017) and masked_autoregressive_flow (Kingma et al., 2016, Papamakarios et al., 2017) normalizing flow architectures.
    • These can be used with arbitrary bijections as transformers, such as Affine or RationalQuadraticSpline (the latter used in neural spline flows; Durkan et al., 2019).
  • block_neural_autoregressive_flow, as introduced by De Cao et al., 2019.
  • planar_flow, as introduced by Rezende and Mohamed, 2015.
  • triangular_spline_flow, introduced here.
  • Training scripts for fitting by maximum likelihood, variational inference, or using contrastive learning for sequential neural posterior estimation (Greenberg et al., 2019; Durkan et al., 2020).
  • A bisection search algorithm that allows inverting some bijections without a known inverse, allowing for example both sampling and density evaluation to be performed with block neural autoregressive flows.

Installation

pip install flowjax

Warning

This package is in its early stages of development and may undergo significant changes, including breaking changes, between major releases. Whilst ideally we should be on version 0.y.z to indicate its state, we have already progressed beyond that stage. Any breaking changes will be in the release notes for each major release.

Development

We can install a version for development as follows

git clone https://github.com/danielward27/flowjax.git
cd flowjax
pip install -e .[dev]
sudo apt-get install pandoc  # Required for building documentation
  • We make use of the Equinox package, which facilitates defining models using a PyTorch-like syntax with Jax.
  • For applying parameterizations, we use paramax.

Citation

If you found this package useful in academic work, please consider citing it using the template below, filling in [version number] and [release year of version] to the appropriate values. Version specific DOIs can be obtained from zenodo if desired.

@software{ward2023flowjax,
  title = {FlowJAX: Distributions and Normalizing Flows in Jax},
  author = {Daniel Ward},
  url = {https://github.com/danielward27/flowjax},
  version = {[version number]},
  year = {[release year of version]},
  doi = {10.5281/zenodo.10402073},
}

Metadata

Release files for flowjax 19.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flowjax 19.1.2
File Size Uploaded
flowjax-19.1.2.tar.gz 477.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flowjax 19.1.2
File Interpreter ABI Platform
flowjax-19.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 538.9 kB

Release files / flowjax-19.1.2.tar.gz

Download URL flowjax-19.1.2.tar.gz
Size 477.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b1b47a5a4d48fa7cb9df95b191613c950643912a96c5fc023d9a8a7944b89d9d
BLAKE2b-256 checksum
How to use checksums
ab315abf794fe9d77322ee7f0d5347209ba34a4f90158a5f38234661b01b8de8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / flowjax-19.1.2-py3-none-any.whl

Download URL flowjax-19.1.2-py3-none-any.whl
Size 61.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c42c668f8591992869ed5954cb67774a60dd0042bbcc749c3bebb604964a600
BLAKE2b-256 checksum
How to use checksums
511bf95ac46e0ed720900242caf1470e0bf6c9a1e454fb7db244baec83975e16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

19.1.2 This release

2 release files

19.1.1

2 release files

19.1.0

2 release files

19.0.0

2 release files

17.2.1

2 release files

17.0.2

2 release files

16.0.0

2 release files

15.0.0

2 release files

13.1.1

2 release files

13.0.1

2 release files

13.0.0

2 release files

12.4.0

2 release files

12.2.0

2 release files

12.1.2

2 release files

12.1.1

2 release files

12.0.1

2 release files

12.0.0

2 release files

11.2.0

2 release files

11.0.0

2 release files

10.1.0

2 release files

10.0.5

2 release files

10.0.4

2 release files

10.0.3

2 release files

10.0.1

2 release files

9.1.0

2 release files

9.0.0

2 release files

8.1.0

2 release files

8.0.0

2 release files

7.0.0

2 release files

6.1.0

2 release files

6.0.0

2 release files

5.0.0

2 release files

4.0.2

2 release files

4.0.0

2 release files

3.0.2

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page