-
-
Notifications
You must be signed in to change notification settings - Fork 984
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
adding RandomVariable container class around Distribution #2448
Conversation
@ecotner thanks for the PR. I stand by what I said in #2441, which is that this design breaks down when users (quite reasonably) try to build expressions that are not invertible or contain more than one random variable, especially if the random variables are not jointly independent. We could raise Even disregarding the multiple-variables issue, I can also foresee a lot of feature creep and maintenance burden, up to reimplementing large swaths of the PyTorch tensor API as I think the best way to proceed with a feature that most closely resembles this PR is to resurrect the However, I still think a better long-term solution to the multiple-variables problem is having |
@ecotner This is indeed a slick little DSL for specifying transforms, and I'd like to be able to expose it in Pyro. I think the safest way to do so in light of @eb8680 valid concerns is to:
Regarding (2), we could see the d = dist.Uniform(0, 1).rv.add(1).mul(0.5).tanh().dist.mask(my_mask).to_event(1)
# \________________/ \_____________________/ \________________________/
# Distribution DSL RandomVariable DSL Distribution DSL where the I realize this is a significant change from your original mixin idea, but at least it keeps your nice method chaining syntax. Would this limited design something you'd still like to work on? |
Thanks guys, those are definitely valid concerns. I wasn't even aware of I like the idea of easily switching between @eb8680 I'm not discouraged at all; I don't think I've ever had a PR accepted on the first try 😉. |
So, I moved everything over to I found a way around it by moving the import inside the Also, do you guys follow the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I think this only needs documentation. I've added a list of documentation tasks to your PR description.
[local import] seems a little hacky.
I'm ok with some hackiness connecting contrib code with non-contrib code. If you do find a better practice let me know.
do you guys follow the
isort
format anymore?
We don't enforce isort
automatically, and I don't know an easy way to enforce subtler linting/formating requirements for community PRs. Also there are a couple files that I believe need non-isort import order, e.g. pyro/distributions/init.py and I haven't figured out how to annotate single lines or single files with isort. Again, if you know how to do this we'd appreciate any code cleanliness tips.
@eb8680 are you ok with this experimental |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Distribution
self.transform
to apply other transformations and return anotherRandomVariable
Documented
.rv
that points toRandomVariable
class.dist
RandomVariable
Tested