-
Notifications
You must be signed in to change notification settings - Fork 218
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
ESS produces the wrong result certain models #1633
Conversation
Tests are failing because of the issue fixed in TuringLang/Bijectors.jl#184 |
for vn in Iterators.flatten(values(vns)) | ||
set_flag!(varinfo, vn, "del") | ||
end |
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.
We should add a context that does this 😛 At least it would be more convenient than dealing with DynamicPPL internals here. I remember that I was very confused and uncertain if I did it correctly when I implemented this. It seemed to work 😬
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.
It works sometimes because in assume
we only check if the flag is set for vns[1]
, but that is only for "sub-symbols". This is the line I'm referring to: https://github.com/TuringLang/DynamicPPL.jl/blob/9083299db3f623136895cae80ef5f10d7fcf8d2c/src/context_implementations.jl#L268. But this won't work if we have more than one key in vi.metadata
or if tilde_assume
and others are called with a varname subsumed e.g. m[2]
.
And this won't be an issue once we have a clear separation between sampling and evaluation. These sorts of bugs show up soooo often (and I agree, it's super-confusing), so looking forward to not having those:)
function DynamicPPL.dot_tilde(ctx::DefaultContext, sampler::Sampler{<:ESS}, right, left, vi) | ||
return DynamicPPL.dot_tilde(ctx, SampleFromPrior(), right, left, vi) |
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.
Was this a bug or is needed because of recent changes in DynamicPPL?
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 was a bug. This is never actually hit and given the arguments I'm assuming it was intended to be a dot_tilde_observe
rather than a dot_tilde_assume
(which is the case when rng
is passed, but because the signature doesn't match the rest of the dot_tilde_assume
, it was never hit). The result was that ESS
didn't work for dotted observations.
@@ -34,14 +34,15 @@ function Bijectors.bijector( | |||
end | |||
|
|||
bs = Bijectors.bijector.(tuple(dists...)) | |||
rs = tuple(ranges...) |
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.
I guess this is not related to ESS?
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.
Correct; this is just to ensure that we have the same behavior as we had before the most recent release of Bijectors.jl. I just noticed it when trying to figure out why the tests weren't passing.
test/test_utils/numerical_tests.jl
Outdated
# Log this so that if something goes wrong, we can identify the | ||
# algorithm and model. | ||
@info "Testing $(alg) on $(m.name)" |
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.
Just put it into a testset
@testset "Testing $(alg) on $(m.name)" for m in mean_of_mean_models
...
end
?
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.
Wait wat?! That works?!
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.
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.
Sick! Did not know that:)
# A collection of models for which the mean-of-means for the posterior should | ||
# be same. |
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.
Sorry, what exactly do you mean with mean-of-means
? And is the value the same as the prior? Or between the models? And only with the default arguments or in general?
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.
I want to have a collection of models which tries out all the combinations of *_tilde_*
, but this means that we'll sometimes have univariate latent variables rather than multivariate (e.g. gdemo5
below). Therefore I compare the mean of the mean of the latent variables rather than the variables directly.
Buuuuut now that we're comparing to the true mean rather than pitting the different models against each other, I guess we don't need to do that 😅
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Pull Request Test Coverage Report for Build 924779474
💛 - Coveralls |
Codecov Report
@@ Coverage Diff @@
## master #1633 +/- ##
==========================================
+ Coverage 78.30% 79.32% +1.02%
==========================================
Files 23 23
Lines 1424 1422 -2
==========================================
+ Hits 1115 1128 +13
+ Misses 309 294 -15
Continue to review full report at Codecov.
|
@devmotion You ready to give it 👍 ? |
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 👍 Maybe test/Project.toml doesn't have to be modified?
thanks, @torfjelde. |
* removed unnecessary exports * updated OptimizationContext * updated ESS smapler * fixed #1633 * fixed bug where ESS didnt support dot_observe * added some additional models to test against * added test for ESS on the mean-of-mean models * patch version bump * added tests on mean_of_mean_models for optimization methods too * fixed bug in bijector after recent update to Bijectors.jl * use exact value in check_mean_of_mean_models * fixed bug in OptimizationContext * just use MvNormal instead of TuringDiagMvNormal in test models * renamed the mean_of_mean models used tests * renamed the mean_of_mean_models in tests to gdemo_models * removed redundant testset block * upper-bound compat entries for Libtask while we wait for bugfix * compat entries with hyphens arent supported on Julia v1.3 * compat entries with hyphens not supported on Julia 1.3 * also test models with literal observe * Update Project.toml Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * forgot to bump DPPL version * Apply suggestions from code review * bump DPPL patch version to fix AdvancedPS samplers * bump patch version Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
* removed unnecessary exports * updated OptimizationContext * updated ESS smapler * fixed #1633 * fixed bug where ESS didnt support dot_observe * added some additional models to test against * added test for ESS on the mean-of-mean models * patch version bump * added tests on mean_of_mean_models for optimization methods too * fixed bug in bijector after recent update to Bijectors.jl * use exact value in check_mean_of_mean_models * fixed bug in OptimizationContext * just use MvNormal instead of TuringDiagMvNormal in test models * renamed the mean_of_mean models used tests * renamed the mean_of_mean_models in tests to gdemo_models * removed redundant testset block * upper-bound compat entries for Libtask while we wait for bugfix * compat entries with hyphens arent supported on Julia v1.3 * compat entries with hyphens not supported on Julia 1.3 * also test models with literal observe * Update Project.toml Co-authored-by: David Widmann <devmotion@users.noreply.github.com> * forgot to bump DPPL version * Apply suggestions from code review * bump DPPL patch version to fix AdvancedPS samplers * bump patch version * updated OptimizationContext to work with the new version of DPPL Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Ref: #1633