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

Manually set tag.test_value instead of using Theano #1876

Closed
timothyb0912 opened this issue Mar 7, 2017 · 0 comments
Closed

Manually set tag.test_value instead of using Theano #1876

timothyb0912 opened this issue Mar 7, 2017 · 0 comments

Comments

@timothyb0912
Copy link

timothyb0912 commented Mar 7, 2017

When theano.config.compute = 'off', PyMC3 throws errors. Specifically, the tags of the theano variables corresponding to most of the PyMC3 random variables and intermediate theano objects do not have a test_value attribute. I think the internal PyMC3 code expects this attribute to exist so that one can determine if the dimensions in one’s model variables are aligned before sampling begins.

This problem affects users who are trying to use theano alongside PyMC3. The issue is related to (and has been noted in) the following github issues: 376, 561, 566, 783, and 1514.

A solution seems to be that when theano.config.compute = 'off', we can set the test values manually on all PyMC3 random variables and on their default values (i.e. the mean, median, and mode's of the distribution). By manually, I just mean using python code instead of relying on Theano.

The following series of steps seem to work (at least for the distributions in continuous.py):

  1. Create test_value for the tag of the theano expression of a distribution's default values.
  2. Call super() in the named distributions after the default distribution values and their tag.test_values are set.
  3. Manually determine the shape of a transformed RV that is going to be created (in transformations.py)
  4. Ensure that all transformation functions manually set the tag.test_value attribute on the theano variables being returned.
  5. Manually set the tag.test_value of observed RV (in model.py)

So far, I've done steps 1 and 2 for the distributions in continuous.py, and step 4 for the transformations in transformations.py. These steps would need to be performed for all of the other distributions (e.g. discrete, multivariate, time series, etc.) as well as any other transformation functions. Also, a bunch of tests would need to be written to ensure that everything works.

Would there be any reason not to go down this route?

It seems like this sort of solution would go along with the sentiment of wrapping theano functionality in python (or in this case re-implementing the functionality for setting test-values).

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

No branches or pull requests

2 participants