Skip to main content

Bayesian Inference with JAX

Project description

Bayinx: Bayesian Inference with JAX

The original aim of this project was to build a PPL in Python that is similar in feel to Stan or Nimble(where there is a nice declarative syntax for defining the model) and allows for arbitrary models(e.g., ones with discrete parameters that may not be just integers); most of this goal has been moved to baycian for the foreseeable future.

Part of the reason for this move is that Rust's ability to embed a "nice" DSL is comparitively easier due to Rust macros; I can define syntax similar to Stan and parse it to valid Rust code. Additionally, the current state of bayinx is relatively functional(plus/minus a few things to clean-up and documentation) and it offers enough functionality for one of my other projects: disize! I plan to rewrite disize in Python with JAX, and bayinx makes it easy to handle constraining transformations, filtering for parameters for gradient calculations, etc.

Instead, this project is narrowing on implementing much of Stan's functionality(restricted to continuously parameterized models, point estimation + vi + mcmc, etc) without most of the nice syntax, at least for versions 0.4.#. Therefore, people will work with target directly and return the density like below:

class NormalDist(Model):
    x: Parameter[Array] = define(shape = (2,))

    def eval(self, data: Dict[str, Array]):
        # Constrain parameters
        self, target = self.constrain_params() # this does nothing for the current model

        # Evaluate x ~ Normal(10.0, 1.0)
        target += normal.logprob(self.x(), 10.0, 1.0).sum()

        return target

I have ideas for using a context manager and implementing Node: Observed/Stochastic classes that will try and replicate what baycian is trying to do, but that is for the future and versions 0.4.# will retain the functionality needed for disize.

TODO

  • For optimization and variational methods offer a way for users to have custom stopping conditions(perhaps stop if a single parameter has converged, etc).
  • Control variates for meanfield VI? Look at https://proceedings.mlr.press/v33/ranganath14.html more closely.
  • Low-rank affine flow?
  • https://arxiv.org/pdf/1803.05649 implement sylvester flows.
  • Learn how to generate documentation.
  • Figure out how to make transform_pars for flows such that there is no performance loss. Noticing some weird behaviour when adding constraints.
  • Look into adaptively tuning ADAM hyperparameters for VI.

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

bayinx-0.4.0.tar.gz (42.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bayinx-0.4.0-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bayinx-0.4.0.tar.gz
  • Upload date:
  • Size: 42.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.16

File hashes

Hashes for bayinx-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6b63a20c6670c2a6d253d558ee0b581b27ee08e21f866b63aa488aa6e3ce125a
MD5 6961d824c28bbfb81613ede7e8f9a88f
BLAKE2b-256 0b447ef104f2c0c64b4e7f36ab4f786d889063909291736b01b7a075202fef69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bayinx-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.16

File hashes

Hashes for bayinx-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b6f5118013d907cb7e874b6037a70baffd3cee762bd9194cd84bf17ee1e6b2d
MD5 cd149c58e61c072c6303a1b80c0e4770
BLAKE2b-256 f8294ca9c90ade3499f98bd63ce880394e33f503b5ff481cd459366e57992ea8

See more details on using hashes here.

Supported by

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