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

raise more informative error message if random variable does not have sampling #422

Closed
dustinvtran opened this issue Jan 25, 2017 · 2 comments

Comments

@dustinvtran
Copy link
Member

when trying to instantiate a random variable that does not have sampling, we get

>>> x = Poisson(lam=5.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "edward/models/random_variable.py", line 80, in __init__
    self._value = self.sample()
  File "/Users/dvt/Envs/venv/lib/python2.7/site-packages/tensorflow/contrib/distributions/python/ops/distribution.py", line 374, in sample
    samples = self.sample_n(total, seed)
  File "/Users/dvt/Envs/venv/lib/python2.7/site-packages/tensorflow/contrib/distributions/python/ops/distribution.py", line 397, in sample_n
    self._check_hasattr(self._sample_n)
AttributeError: 'Poisson' object has no attribute '_sample_n'

this error is a huge point of confusion for our users. we should catch this error and raise our own with a more informative message.

@laufere
Copy link

laufere commented Jan 30, 2017

If I understand correctly (since as a user I was hugely confused :)) that means that edward does not support Poisson as of yet? But it is still possible to instantiate a Poisson random variable since tensorflow provides it as a distribution (with le pmf or logpmf being the minimal requirement to be a valid distribution)?

@dustinvtran
Copy link
Member Author

dustinvtran commented Jan 30, 2017

I recommend looking at the Advanced Settings in http://edwardlib.org/api/model-development. It shows how you can implement your own sampling if desired, or how to instantiate a Poisson just as a likelihood if you don't want to implement sampling.

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