working towards nested iarange in tracegraph_elbo#780
Merged
Conversation
…_vectorized_map_data_in_elbo_with_superfluous_rv
7 tasks
fritzo
requested changes
Feb 26, 2018
Member
fritzo
left a comment
There was a problem hiding this comment.
Nice tests in test_compute_downstream_costs.py!
|
|
||
| import warnings | ||
|
|
||
| from operator import itemgetter |
Member
There was a problem hiding this comment.
nit: this should be in the builtins section above. I recommend setting up isort integration in vim.
| topo_sort_guide_nodes = list(reversed(list(networkx.topological_sort(guide_trace)))) | ||
| topo_sort_guide_nodes = [x for x in topo_sort_guide_nodes | ||
| if guide_trace.nodes[x]["type"] == "sample"] | ||
| ordered_guide_nodes_dict = dict(list(zip(topo_sort_guide_nodes, list(range(len(topo_sort_guide_nodes)))))) |
Member
There was a problem hiding this comment.
nit: maybe simplify to {n: i for i, n in enumerate(topo_sorted_guide_nodes)}?
| if model_trace.nodes[x]["type"] == "sample"] | ||
|
|
||
| for node in all_nodes: | ||
| if printhappy: |
| "Falling back to higher-variance gradient estimator. " | ||
| "Try to avoid these issues in your model and guide:\n{}".format("\n".join( | ||
| guide_vec_md_info["warnings"] | model_vec_md_info["warnings"]))) | ||
| # guide_vec_md_condition = guide_vec_md_info['rao-blackwellization-condition'] |
| for k in range(1, 1 + source.dim()): | ||
| if source.size(-k) > target.size(-k): | ||
| source = source.sum(-k, keepdim=True) | ||
| # XXX make this more efficient |
|
|
||
| # construct data structure consumed by tracegraph_kl_qp | ||
| if vectorized_map_data_info['rao-blackwellization-condition']: | ||
| if True or vectorized_map_data_info['rao-blackwellization-condition']: |
| with pyro.iarange("iarange_triple1", 6) as ind_triple1: | ||
| with pyro.iarange("iarange_triple2", 7) as ind_triple2: | ||
| with pyro.iarange("iarange_triple3", 9) as ind_triple3: | ||
| pyro.sample("z0", dist.Bernoulli(p2).reshape(sample_shape=[len(ind_triple1), |
Member
There was a problem hiding this comment.
Shouldn't this be
sample_shape=[len(ind_triple3), len(ind_triple2), len(ind_triple1)]This will be checked more strictly in my #806
| assert_error(model, guide, trace_graph=trace_graph) | ||
|
|
||
|
|
||
| @pytest.mark.skip('TODO FIX ME') |
Member
There was a problem hiding this comment.
This should be xfail rather than skip
|
|
||
|
|
||
| def test_nested_iarange_iarange_warning(): | ||
| @pytest.mark.xfail(reason="https://github.com/uber/pyro/issues/370") |
Member
There was a problem hiding this comment.
Does this still xfail? It passes on my branch in #806 (with some changes) Ditto for all tests marked xfail below.
Collaborator
Author
|
@fritzo ready for merge? |
fritzo
approved these changes
Feb 27, 2018
This was referenced Feb 27, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
add nested iarange support to tracegraph_elbo. clean-up to follow in #816