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

Cannot pass a random variable to TransformedDistribution #325

Open
AdrienCorenflos opened this issue May 12, 2020 · 2 comments
Open

Cannot pass a random variable to TransformedDistribution #325

AdrienCorenflos opened this issue May 12, 2020 · 2 comments

Comments

@AdrienCorenflos
Copy link

Hi,

I am using edward2==0.0.1 in combination with tensorflow_probability==0.9.0 and tensorflow==2.1.0, all installed from pip.

I am facing an issue with ed.TransformedDistribution that feel like a regression to me.

import edward2 as ed
import tensorflow_probability as tfp
tfb = tfp.bijectors

normal = ed.Normal(0., 1.)
shifted_normal = ed.TransformedDistribution(normal, tfb.Shift(0.5))
# This raises with AttributeError: 'RandomVariable' object has no attribute 'name'

I can patch the case 1 by passing normal.distribution to ed.TransformedDistribution but I don't think this is desirable.

@dustinvtran
Copy link
Member

dustinvtran commented May 13, 2020

Thanks for raising this! In the code, we minimally wrap all distributions as ed2 rvs, and the input types are the same as distributions (this is why ed.TransformedDistribution still takes a distribution as input).

One way to resolve this is to augment all higher-order distributions that take a distribution as input to take a RandomVariable as input (that is, raising all tfp.Distribution types to ed.RandomVariable types). It's easy to do this on a one-off basis, but we haven't quite figured out how to automate this which would be better for maintenance.

@AdrienCorenflos
Copy link
Author

Ah yes that sounds tricky if you don't want to break the open close principles.

Also even doing it on a case by case basis may prove complicated.
For example, someone coded a distribution by subclassing the Transformed Distribution instead of composing it (I might send a PR for that one...), so you wouldn't be able to check the bases of the classes not their attributes either...

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