Skip to main content

Diffusion meets sampling

Project description

fusions

tests Code style: black PyPI version

Diffusion meets (nested) sampling

A miniminal implementation of generative diffusion models in JAX (Flax). Tuned for usage in building emulators for scientific models, particularly where MCMC sampling is tractable and used.

from fusions.cfm import CFM
from lsbi.model import LinearMixtureModel
from anesthetic import MCMCSamples
import matplotlib.pyplot as plt
import numpy as np


dims = 5
Model = LinearMixtureModel(
    M=np.stack([np.eye(dims), -np.eye(dims)]),
    C=np.eye(dims)*0.1,
)

data = Model.evidence().rvs(1)

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.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

fusions-0.4.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file fusions-0.4.0.tar.gz.

File metadata

  • Download URL: fusions-0.4.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for fusions-0.4.0.tar.gz
Algorithm Hash digest
SHA256 13d23dc873f96fd1d9dfaf4f3060460742ad522bb23d5721e6ac97351fcc3f6f
MD5 c6cce0f3a13e40eaec90550819c9fca2
BLAKE2b-256 aef874edb03f7c2825a76806e342f19d720a4b5a901588947df889a995d9d1f1

See more details on using hashes here.

File details

Details for the file fusions-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: fusions-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for fusions-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d45cb2ed61c3e66c881bc4eb1e255f86501f279fdc7136a89b360d4de4b14f78
MD5 29672c72cf9346ed415f0223044bd9ee
BLAKE2b-256 1b6844893029ed72b6671c3c264ff16c4d84a38f2dba7032fcdf33add4904d2a

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