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

Fix gradient scaling when subsampling #533

Merged
merged 2 commits into from
Nov 8, 2017
Merged

Conversation

fritzo
Copy link
Member

@fritzo fritzo commented Nov 8, 2017

Fixes #531

This implements a quick-and-dirty fix for double counted site["scale"] when subsampling. This corresponds to Solution 2 in #531. The author would like to merge this PR first, and later clean up by implementing Solution 1 in #531.

Tested

Added a regression test in tests/infer/test_gradient.py that compares gradient estimates with and without subsampling. Results are:

which elbo distribution Before this PR After this PR
Trace reparametrized PASS PASS
Trace non-reparametrized FAIL PASS
TraceGraph reparametrized PASS PASS
TraceGraph non-reparametrized FAIL PASS

assert_equal(actual_grads, expected_grads, prec=precision)


# The golden values below (mu_q_expected/log_sig_q_expected/) need to be updated each time
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was moved from test_gradient_step.py. The only changes were to add ids to the @pytest.mark.parameterize decorators.

@fritzo fritzo added awaiting review and removed WIP labels Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

site["scale"] is double counted at non-reparameterized sites
2 participants