Accelerate Sequential Posterior Inference via REuse
Project description
aspire: Accelerated Sequential Posterior Inference via REuse
aspire is a framework for reusing existing posterior samples to obtain new results at a reduced cost.
Installation
aspire can be installed from PyPI using pip. By default, you need to install
one of the backends for the normalizing flows, either torch or jax.
We also recommend installing minipcn if using the smc sampler:
Torch
We recommend installing torch manually to ensure correct CPU/CUDA versions are
installed. See the PyTorch installation instructions
for more details.
pip install aspire-inference[torch,minipcn]
Jax:
We recommend install jax manually to ensure the correct GPU/CUDA versions
are installed. See the jax documentation for details
pip install aspire-inference[jax,minipcn]
Important: the name of aspire on PyPI is aspire-inference but once installed
the package can be imported and used as aspire.
Quickstart
import numpy as np
from aspire import Aspire, Samples
# Define a log-likelihood and log-prior
def log_likelihood(samples):
x = samples.x
return -0.5 * np.sum(x**2, axis=-1)
def log_prior(samples):
return -0.5 * np.sum(samples.x**2, axis=-1)
# Create the initial samples
init = Samples(np.random.normal(size=(2_000, 4)))
# Define the aspire object
aspire = Aspire(
log_likelihood=log_likelihood,
log_prior=log_prior,
dims=4,
parameters=[f"x{i}" for i in range(4)],
)
# Fit the normalizing flow
aspire.fit(init, n_epochs=20)
# Sample the posterior
posterior = aspire.sample_posterior(
sampler="smc",
n_samples=500,
sampler_kwargs=dict(n_steps=100),
)
# Plot the posterior distribution
posterior.plot_corner()
Documentation
See the documentation on ReadTheDocs.
Citation
If you use aspire in your work please cite the DOI and paper.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aspire_inference-0.1.0a19.tar.gz.
File metadata
- Download URL: aspire_inference-0.1.0a19.tar.gz
- Upload date:
- Size: 85.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f335296be770a57a306a20b0fe3fad72adb5c523c1ff7e71f573f52df761496d
|
|
| MD5 |
f4f79616bdd0ad8709fc89446514d083
|
|
| BLAKE2b-256 |
42b9567af6083fe54b3a44db5406f5fc1d3f4540ed9c13c738f346ce6dae6687
|
Provenance
The following attestation bundles were made for aspire_inference-0.1.0a19.tar.gz:
Publisher:
publish.yml on mj-will/aspire
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aspire_inference-0.1.0a19.tar.gz -
Subject digest:
f335296be770a57a306a20b0fe3fad72adb5c523c1ff7e71f573f52df761496d - Sigstore transparency entry: 1181342884
- Sigstore integration time:
-
Permalink:
mj-will/aspire@2debbdd455d43a38d501d50f196f7e7bfd680b44 -
Branch / Tag:
refs/tags/v0.1.0a19 - Owner: https://github.com/mj-will
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2debbdd455d43a38d501d50f196f7e7bfd680b44 -
Trigger Event:
release
-
Statement type:
File details
Details for the file aspire_inference-0.1.0a19-py3-none-any.whl.
File metadata
- Download URL: aspire_inference-0.1.0a19-py3-none-any.whl
- Upload date:
- Size: 64.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6df65e192903e516f90c603dd81eba4d550bae68885371a26b8e9aa50f4a6fb2
|
|
| MD5 |
e12e7b24a4d6588d19561fc636a9fa5c
|
|
| BLAKE2b-256 |
baa419794de5557a62f1968fab0eaab2c566d902152feca0da1ae4a8279f676f
|
Provenance
The following attestation bundles were made for aspire_inference-0.1.0a19-py3-none-any.whl:
Publisher:
publish.yml on mj-will/aspire
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aspire_inference-0.1.0a19-py3-none-any.whl -
Subject digest:
6df65e192903e516f90c603dd81eba4d550bae68885371a26b8e9aa50f4a6fb2 - Sigstore transparency entry: 1181342887
- Sigstore integration time:
-
Permalink:
mj-will/aspire@2debbdd455d43a38d501d50f196f7e7bfd680b44 -
Branch / Tag:
refs/tags/v0.1.0a19 - Owner: https://github.com/mj-will
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2debbdd455d43a38d501d50f196f7e7bfd680b44 -
Trigger Event:
release
-
Statement type: