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
The core JAX package supports Python 3.9 and newer.
python -m pip install bayesflux
For PDE sampling and likelihoods, install legacy FEniCS/DOLFIN 2019.1 with PETSc first. The following commands create a Python 3.11 environment and install hIPPYlib and hickle through the BayesFlux extra.
conda create -n bayesflux-fenics -c conda-forge python=3.11 fenics=2019.1.0 pip
conda activate bayesflux-fenics
python -m pip install 'bayesflux[hippylib]'
Projects that use the PDE functionality can declare bayesflux[hippylib] as a
dependency and direct users to the FEniCS environment setup above.
Encoded Gaussian PDE likelihood
The local hIPPYlib wrapper evaluates the Gaussian likelihood of the retained observations. For an output encoder E, physical noise covariance Gamma, and PDE prediction G(m), it uses residual y_reduced - E.T @ G(m) and covariance E.T @ Gamma @ E. With the coupled noise-whitened basis the reduced covariance is identity. The gradient uses one Jacobian-transpose action for each sample. The input is parameter_offset + input_decoder @ z. For standard-normal centered coordinates, pass parameter_offset=prior_mean. For preprojected training data, projection_center=prior_mean evaluates the forward model on the same affine subspace and stores the usual raw dinox input coefficients. The wrapper accepts stock hIPPYlib noise variance or a custom noise precision and checks their consistency when both are supplied. Solve failures propagate to the caller.
Metadata
Release files for BayesFlux 0.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bayesflux-0.10.0.tar.gz | 32.1 kB | Without provenance | Details for bayesflux-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bayesflux-0.10.0-py3-none-any.whl | Python 3 | none | any | Details for bayesflux-0.10.0-py3-none-any.whl |
Total release size: 56.6 kB
Release files / bayesflux-0.10.0.tar.gz
| Download URL | bayesflux-0.10.0.tar.gz |
|---|---|
| Size | 32.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13aa38755833ae669cdc31d8f79660a6ad425aa81ef0a22adf19db37294caf31
|
|
BLAKE2b-256 checksum How to use checksums |
a3d2ec1b6b6be7e1913cd6a6d6a04e1a282e7b1db7e9805a81c82db6c7d3c642
|
| 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.10.0-py3-none-any.whl
| Download URL | bayesflux-0.10.0-py3-none-any.whl |
|---|---|
| Size | 24.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
613ccd61ff715d1289f91b3bba4c526df24667875cad90e3c19096fb1085884d
|
|
BLAKE2b-256 checksum How to use checksums |
bbbb571d28c0b4d508efbf5594a80b535b54147f6f9c7b06473d6798ed8e6087
|
| 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.10.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.