Skip to content

pyro-ppl/pyro-models

Repository files navigation

Pyro Models

Models are generated by a custom stan-to-pyro transpiler then manually modified for Pyro 0.3 compatibility, so there may be boilerplate in each example that is unnecessary to actually run the code. Models are from the Stan examples.

The data corresponding to each model is in JSON format and named [model_file].py.json. See test_models.py to see an example of how to run a model.

The interface is unstable and may change in the future. Tested on PyTorch 1.0 and Pyro 0.3.

Note

Initialized variables are uniformly sampled within their domains.

- real<lower=0,upper=100> sigma;
+ sigma = pyro.sample("sigma", dist.Uniform(0., 100.))

Constrained samples from improper distribution are sampled from a HalfCauchy:

- real<lower=0> sigma;
+ sigma_a1 =  pyro.sample("sigma", dist.HalfCauchy(2.))

For inference to work, you may have to change the initializations of the model parameters.

Installation and Usage

To install the package, clone the repository to a directory on your machine and run python setup.py install or python setup.py develop (depending on whether you want to edit the library).

Subsequently, to load the models:

import pyro_models
models = pyro_models.load()

The variable models is a dictionary whose keys are the unique model name qualified by the collection that it is from, and whose value is a dictionary of model metadata, including the Pyro model function. For instance, the model beetles from the BUGS model collection is in models['bugs.beetles'].

See tests/test_models.py for a full demonstration of how to load a model and its dataset and learn the guide program by stochastic variational inference (SVI).

Contributions

Contributions welcome! Contributed examples need not follow the format of the current examples since they were automatically transpiled. However, please do include the data (or a toy dataset your example runs on).

If you have a polished example or a paper replication, you might want to consider contributing it to the Pyro examples.

Citation

If you use these models in your research, please consider citing:

@inproceedings{chen2018transpiling,
  title={Transpiling Stan models to Pyro},
  author={Chen, Jonathan P. and Singh, Rohit and Bingham, Eli and Goodman, Noah},
  booktitle={The International Conference on Probabilistic Programming},
  year={2018}
}

About

Repository of models in Pyro

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •