Skip to main content

BayesFlux

BayesFlux is a JAX Python package that provides Fast Linear algebra sUbspace eXtraction for Bayesian inverse problems built off https://github.com/joshuawchen/randLAX.

Features

  • Active Subspace for parameter dimension reduction
  • Informative Output Subspace for data dimension reduction
  • Coupled parameter and data subspaces fitted to a specified pair of ranks

Coupled dimension reduction

Given Jacobians of a forward model at prior samples, coupled_dimension_reduction alternates between the parameter eigenspace conditional on the current data subspace and the data eigenspace conditional on the updated parameter subspace. It implements Algorithm 1 of Chen, Arnaud, Baptista and Zahm. The existing information_theoretic_dimension_reduction computes the independent diagnostics of Baptista, Marzouk and Zahm. Coupled algorithm · Authors' implementation · Independent diagnostics

from bayesflux.subspace_detection import coupled_dimension_reduction

# J_samples has shape (samples, observations, parameters).
bases = coupled_dimension_reduction(
    key=42,
    J_samples=J_samples,
    noise_precision=noise_precision,
    prior_precision=prior_precision,
    max_input_dimension=4,
    max_output_dimension=2,
)
X_reduced = (X - prior_mean) @ bases["input"]["encoder"]
Y_reduced = Y @ bases["output"]["encoder"]
J_reduced = bases["output"]["encoder"].T @ J_samples @ bases["input"]["decoder"]

Each precision can be a positive scalar or a dense positive definite matrix. The seed initializes the data subspace. To start from a known subspace, pass its orthonormal columns in whitened data coordinates as initial_output_basis. Each sweep increases or preserves the mean squared Frobenius norm of the reduced Jacobians. Inspect bases["diagnostics"]["objective_history"] to track this objective. The default relative tolerance is 1e-6 over at most 20 full sweeps. Set tolerance=None to run a fixed number of sweeps. Fit each desired pair of ranks independently since either rank can change both optimal subspaces.

Installation

Core Installation (JAX-only functionality)

You can install the core BayesFlux package using pip:

pip install bayesflux

This installs the JAX-based functionality only and does not require Fenics or hippylib.

Installation with hippylib Support (Requires Fenics)

Some BayesFlux functionality depends on hippylib, which requires Fenics 2019.1.

Fenics has system-level dependencies and cannot be reliably installed via pip alone. You must first create a conda environment.

Step 1 — Create a Fenics environment

conda create -n fenics-2019.1_env -c conda-forge fenics==2019.1.0
conda activate fenics-2019.1_env

Step 2 — Install BayesFlux with the hippylib extra

pip install bayesflux[hippylib]

This installs:

  • hippylib
  • hickle
  • bayesflux

Make sure the conda environment is activated before running pip install.

For Developers

If your software depends on BayesFlux with hippylib functionality, declare the dependency in your pyproject.toml as:

dependencies = [
    "bayesflux[hippylib]>=<minimum_version>"
]

However, your users must still create the Fenics conda environment before installing your software:

conda create -n fenics-2019.1_env -c conda-forge fenics==2019.1.0
conda activate fenics-2019.1_env
pip install your_package

Important: pip cannot install Fenics. Any software depending on bayesflux[hippylib] must document the required conda environment setup.

Requirements

  • Python 3.9+

Metadata

Release files for BayesFlux 0.9.0

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

Source distribution (sdist)

Source distribution for BayesFlux 0.9.0
File Size Uploaded Provenance Actions
bayesflux-0.9.0.tar.gz 20.9 kB Without provenance Details for bayesflux-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for BayesFlux 0.9.0
File Interpreter ABI Platform Actions
bayesflux-0.9.0-py3-none-any.whl Python 3 none any Details for bayesflux-0.9.0-py3-none-any.whl

Total release size: 43.5 kB

Release files / bayesflux-0.9.0.tar.gz

Download URL bayesflux-0.9.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0d909c5eaf96eefb3998a08b6f5b968091b67f3a8a374c23f549fa9a93d792ec
BLAKE2b-256 checksum
How to use checksums
bbcb3992398b028f8b960c2d96912cb6ebf2a1136c1a975f2eef3683c72f8c26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / bayesflux-0.9.0-py3-none-any.whl

Download URL bayesflux-0.9.0-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88205a7408882c44b6053aebb8cacfffe8c7d9a860f443b27be50c39c3106a41
BLAKE2b-256 checksum
How to use checksums
39b10f078ef73cde00cf64ba4e8c903bce30ffbf5165d1958224d7741dd593af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for BayesFlux 0.9.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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