Diffusion meets sampling
Project description
fusions
Diffusion meets (nested) sampling
A miniminal implementation of diffusion models in JAX (Flax). Tuned for usage in building emulators for scientific models, particularly where MCMC sampling is tractable and used.
Quickstart
Install fusions and lsbi from pypi
pip install lsbi fusions
create a 5D sampling problem then train a flow matched model to approximate the posterior
from fusions.cfm import CFM
from lsbi.model import MixtureModel
from anesthetic import MCMCSamples
import matplotlib.pyplot as plt
import numpy as np
dims = 5
Model = MixtureModel(
M=np.stack([np.eye(dims), -np.eye(dims)]),
C=np.eye(dims)*0.1,
)
data = Model.evidence().rvs()
diffusion = CFM(Model.prior())
# diffusion = CFM(dims)
diffusion.train(Model.posterior(data).rvs(1000))
a = MCMCSamples(Model.posterior(data).rvs(500)).plot_2d(np.arange(dims))
MCMCSamples(diffusion.rvs(500)).plot_2d(a)
plt.show()
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
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 fusions-0.4.3.tar.gz.
File metadata
- Download URL: fusions-0.4.3.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c523ed4b98e6693ba65e9e59a5a0df2eb09c8cde35e11154df901391edbabe5
|
|
| MD5 |
7f8c8791f1b7545160a7d080439c7003
|
|
| BLAKE2b-256 |
a2e9f57bc0dc1e34dada2a2e98d6850428dcf76c8868ccab6f1efa9f9620ce70
|
File details
Details for the file fusions-0.4.3-py3-none-any.whl.
File metadata
- Download URL: fusions-0.4.3-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ef3cd52e5eda6c0f350c67913041703ce20f1a8c6f07d6fc6207f651c7b4aa6
|
|
| MD5 |
7600836cde3b1b28b53ea4ec523f00aa
|
|
| BLAKE2b-256 |
69ba548f64128921cb392f013f1c81c791b2bc22541668cf2ed99bedbf1d67f9
|