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

enable manual specification of model gradient and wrapper for Stan models #14

Closed
dustinvtran opened this issue Feb 21, 2016 · 2 comments

Comments

@dustinvtran
Copy link
Member

Our algorithms perform inference on a Model class and requires only one thing from the class: the method log_prob(self, zs), which takes a n_minibatch x d matrix of latent variables z and outputs a vector [log p(x, z_{1,:}), ..., log p(x, z_{n_minibatch,:})]^T. (Any data x is fixed and stored inside the class.)

In cases where we use the reparameterization gradient, we also require the gradient of the log_prob() function with respect to z. This is done automatically if log_prob() is implemented in TensorFlow.

We want to extend this to a manual specification of the gradient. The motivation is twofold:

  1. we want to be able to specify the model with a Stan program and use its log_prob() and grad_log_prob functions.
  2. a user may not be familiar with TensorFlow and prefers to implement the model in vanilla numpy/scipy, in which they will hand-derive the gradient;

All of this should go behind the scenes: the algorithms will simply check if the grad_log_prob() method exists. If it exists, it uses the function. If it doesn't exist, then it tries to autodiff it using TensorFlow. This solves 1. To solve 2, we also require a wrapper than wraps a Stan program and data into this class with the two methods log_prob and grad_log_prob.

@dustinvtran dustinvtran changed the title Enable manual specification of model gradient for inferring Stan models Enable manual specification of model gradient and wrapper for Stan models Feb 21, 2016
@dustinvtran dustinvtran changed the title Enable manual specification of model gradient and wrapper for Stan models enable manual specification of model gradient and wrapper for Stan models Feb 21, 2016
@dustinvtran
Copy link
Member Author

53242c0

  • Inference on models written in Stan or NumPy/SciPy are now supported using the score function gradient.

The remaining task is to enable automatic model gradients, so the reparameterization gradient is also available.

@dustinvtran dustinvtran added this to the public release milestone Mar 15, 2016
@dustinvtran dustinvtran changed the title enable manual specification of model gradient and wrapper for Stan models enable manual specification of model gradient and wrapper for Python, Stan, and PyMC3 models Jul 10, 2016
@dustinvtran dustinvtran changed the title enable manual specification of model gradient and wrapper for Python, Stan, and PyMC3 models enable manual specification of model gradient for Python, Stan, and PyMC3 models Jul 10, 2016
@dustinvtran dustinvtran changed the title enable manual specification of model gradient for Python, Stan, and PyMC3 models enable manual specification of model gradient and wrapper for Stan models Jul 10, 2016
@dustinvtran
Copy link
Member Author

I'm closing this issue and making another, which refers directly to the issue of enabling gradients in all the model wrappers. see #163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant