Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support gradients in TensorFlow for Python, PyMC3, and Stan models #164

Closed
wants to merge 3 commits into from

Conversation

dustinvtran
Copy link
Member

@dustinvtran dustinvtran commented Jul 10, 2016

This pull request is a work in progress. Comments are welcome from interested parties, and also feedback on the implementation.

Gradients of the log density are now supported for all model wrappers for use within a TensorFlow session.

  • PythonModel uses autograd's automatic differentiation.
  • PyMC3Model uses PyMC3's automatic differentiation.
  • StanModel uses Stan's automatic differentiation.

In all wrappers, the gradient can be overwritten by manually specifying it. The manual gradient is written in native Python. This is useful for speeding up computation: manual gradients are often faster than automatic gradients (especially reverse-mode autodiff). It is also useful for the PythonModel in cases where its gradient is not supported by autograd.

Examples showing proof of concept are added. Each example is a normal posterior; inference is done via variational inference with the reparameterization trick, which uses the model gradient. The model is written in 4 ways:

  1. PythonModel (with autograd).
  2. PythonModel with a manually specified gradient.
  3. PyMC3Model.
  4. StanModel.

References.

@twiecki
Copy link
Contributor

twiecki commented Jul 11, 2016

Neat. Want to merge this first and then I could add pymc3 gradients?

@dustinvtran
Copy link
Member Author

Sure sounds good! Once one of them is written and working properly, e.g., PythonModel, it should be easy to do the same for the others. The only nuance may be changing the various input types so they are compatible to be passed into PyMC3 or Stan or autograd's gradient function.

@dustinvtran
Copy link
Member Author

model wrappers are now deprecated

@dustinvtran dustinvtran deleted the feature/python-gradient branch November 16, 2016 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support TensorFlow gradients for PyMC3Model, PythonModel, StanModel
2 participants