Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Pyro integration #895
Pyro integration #895
Changes from 8 commits
062abc5
b274734
a25ee28
d9f94e1
b1556b4
4f02760
507b5cc
73b8122
68844b5
7c943b9
9dac91f
b19fc05
e90dacd
9f6c4ae
8ad0233
e7fb932
7968873
f9bfec4
d78f29a
d7b8005
f982827
427c5b4
2f9f8a6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Warning: it's dangerous to set stateful default arguments. In this case the same default
Trace_ELBO
instance will be shared by all models and (details below) bad things may happen. I'd recommend defaulting toNone
and doing a standardif loss_fn is None: loss_fn = pyro.infer.Trace_ELBO()
.Each
Trace_ELBO
instance guesses and stores the number of plates in its model, and assumes it will be associated with only a single model. If you use it with a different model with a different number of plates, you might see tensor shape errors.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.
Technical detail: One of the rules of
PyroModule
s is that the model and guide must be separatePyroModule
s, and cannot be contained in a singlePyroModule
; however they can be contained in a singlenn.Module
. You might consider refactoring to separatePyroBaseModuleClass
from some sort ofPyroModelClass
like this (wheres <: t
meansissubclass(s, t)
):Basically "a model can't have its guide as an attribute".
The reason is due to
PyroModule
naming schemes and caching ofpyro.sample
calls. Ifmodel
andguide
are contained in a singlePyroModule
there may be weird conflicts in both names and thepyro.sample
cache.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 is super helpful!