Skip to main content

Diffusion meets sampling

Project description

fusions

tests Code style: black PyPI version

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

fusions-0.4.3.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

fusions-0.4.3-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

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

Hashes for fusions-0.4.3.tar.gz
Algorithm Hash digest
SHA256 7c523ed4b98e6693ba65e9e59a5a0df2eb09c8cde35e11154df901391edbabe5
MD5 7f8c8791f1b7545160a7d080439c7003
BLAKE2b-256 a2e9f57bc0dc1e34dada2a2e98d6850428dcf76c8868ccab6f1efa9f9620ce70

See more details on using hashes here.

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

Hashes for fusions-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6ef3cd52e5eda6c0f350c67913041703ce20f1a8c6f07d6fc6207f651c7b4aa6
MD5 7600836cde3b1b28b53ea4ec523f00aa
BLAKE2b-256 69ba548f64128921cb392f013f1c81c791b2bc22541668cf2ed99bedbf1d67f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page