{"action":"created","comment":{"url":"https://api.github.com/repos/uber/pyro/pulls/comments/183264061","pull_request_review_id":114227756,"id":183264061,"diff_hunk":"@@ -159,11 +170,11 @@ def __call__(self, *args, **kwargs):\n         stores the arguments and return value of the function in special sites,\n         and returns self.fn's return value\n         \"\"\"\n-        self.msngr.trace = Trace(graph_type=self.msngr.graph_type)\n-        self.msngr.trace.add_node(\"_INPUT\",\n-                                  name=\"_INPUT\", type=\"args\",\n-                                  args=args, kwargs=kwargs)\n-        ret = super(TraceHandler, self).__call__(*args, **kwargs)\n+        with self.msngr:","path":"pyro/poutine/trace_poutine.py","position":60,"original_position":60,"commit_id":"643739495ba0030634c96ab5b8c9a2cd21e1bbac","original_commit_id":"643739495ba0030634c96ab5b8c9a2cd21e1bbac","user":{"login":"fritzo","id":648532,"avatar_url":"https://avatars0.githubusercontent.com/u/648532?v=4","gravatar_id":"","url":"https://api.github.com/users/fritzo","html_url":"https://github.com/fritzo","followers_url":"https://api.github.com/users/fritzo/followers","following_url":"https://api.github.com/users/fritzo/following{/other_user}","gists_url":"https://api.github.com/users/fritzo/gists{/gist_id}","starred_url":"https://api.github.com/users/fritzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fritzo/subscriptions","organizations_url":"https://api.github.com/users/fritzo/orgs","repos_url":"https://api.github.com/users/fritzo/repos","events_url":"https://api.github.com/users/fritzo/events{/privacy}","received_events_url":"https://api.github.com/users/fritzo/received_events","type":"User","site_admin":false},"body":"Interesting, does this fix a bug related to exception handling? I don't understand the difference between old and new versions.","created_at":"2018-04-23T02:15:54Z","updated_at":"2018-04-23T02:27:19Z","html_url":"https://github.com/uber/pyro/pull/1060#discussion_r183264061","pull_request_url":"https://api.github.com/repos/uber/pyro/pulls/1060","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/uber/pyro/pulls/comments/183264061"},"html":{"href":"https://github.com/uber/pyro/pull/1060#discussion_r183264061"},"pull_request":{"href":"https://api.github.com/repos/uber/pyro/pulls/1060"}}},"pull_request":{"url":"https://api.github.com/repos/uber/pyro/pulls/1060","id":183309464,"html_url":"https://github.com/uber/pyro/pull/1060","diff_url":"https://github.com/uber/pyro/pull/1060.diff","patch_url":"https://github.com/uber/pyro/pull/1060.patch","issue_url":"https://api.github.com/repos/uber/pyro/issues/1060","number":1060,"state":"open","locked":false,"title":"Improve support for custom losses in SVI","user":{"login":"eb8680","id":2032320,"avatar_url":"https://avatars0.githubusercontent.com/u/2032320?v=4","gravatar_id":"","url":"https://api.github.com/users/eb8680","html_url":"https://github.com/eb8680","followers_url":"https://api.github.com/users/eb8680/followers","following_url":"https://api.github.com/users/eb8680/following{/other_user}","gists_url":"https://api.github.com/users/eb8680/gists{/gist_id}","starred_url":"https://api.github.com/users/eb8680/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eb8680/subscriptions","organizations_url":"https://api.github.com/users/eb8680/orgs","repos_url":"https://api.github.com/users/eb8680/repos","events_url":"https://api.github.com/users/eb8680/events{/privacy}","received_events_url":"https://api.github.com/users/eb8680/received_events","type":"User","site_admin":false},"body":"This PR removes a bit of cruft in SVI so that it's easier to work with custom losses.  In particular, it:\r\n1. Removes `ParamStoreDict.mark_param_active()` and related machinery\r\n2. Replaces that machinery with a `poutine.trace` in `SVI.step` so that users can simply define a loss and not worry about moving parameters around\r\n3. Adds a `param_only` flag to `TraceMessenger` that allows `poutine.trace` to record only parameter sites\r\n4. Removes the restriction in `SVI` requiring `loss` to be an `ELBO` object\r\n5. Restores a default value for `SVI.loss_and_grads` (calling backward on the result of `SVI.loss`)\r\n\r\nThe upshot is that now, to create a custom loss, all that's needed is to define it as a function that takes in a model, guide, and any other arguments necessary to compute it and returns a differentiable scalar loss value.  For example:\r\n```python\r\ndef simple_elbo(model, guide, *args, **kwargs):\r\n    guide_trace = poutine.trace(guide).get_trace(*args, **kwargs)\r\n    model_trace = poutine.trace(\r\n        poutine.replay(model, trace=guide_trace)).get_trace(*args, **kwargs)\r\n    return -1*(model_trace.log_prob_sum() - guide_trace.log_prob_sum())\r\n\r\nsvi = SVI(model, guide, optim, loss=simple_elbo)\r\nlosses = []\r\nfor i in range(N):\r\n    losses.append(svi.step())\r\n```","created_at":"2018-04-23T01:59:25Z","updated_at":"2018-04-23T02:27:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b926039be5988e7c7c5aa292452184cb481795f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":704871691,"url":"https://api.github.com/repos/uber/pyro/labels/awaiting%20review","name":"awaiting review","color":"fbca04","default":false}],"milestone":{"url":"https://api.github.com/repos/uber/pyro/milestones/3","html_url":"https://github.com/uber/pyro/milestone/3","labels_url":"https://api.github.com/repos/uber/pyro/milestones/3/labels","id":2920331,"number":3,"title":"0.2.0 release","description":"Pyro 0.2.0 will make major breaking changes:\r\n- PyTorch distributions\r\n- multiple batch dimensions","creator":{"login":"ngoodman","id":461193,"avatar_url":"https://avatars1.githubusercontent.com/u/461193?v=4","gravatar_id":"","url":"https://api.github.com/users/ngoodman","html_url":"https://github.com/ngoodman","followers_url":"https://api.github.com/users/ngoodman/followers","following_url":"https://api.github.com/users/ngoodman/following{/other_user}","gists_url":"https://api.github.com/users/ngoodman/gists{/gist_id}","starred_url":"https://api.github.com/users/ngoodman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngoodman/subscriptions","organizations_url":"https://api.github.com/users/ngoodman/orgs","repos_url":"https://api.github.com/users/ngoodman/repos","events_url":"https://api.github.com/users/ngoodman/events{/privacy}","received_events_url":"https://api.github.com/users/ngoodman/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":35,"state":"open","created_at":"2017-11-17T17:45:46Z","updated_at":"2018-04-23T01:59:25Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/uber/pyro/pulls/1060/commits","review_comments_url":"https://api.github.com/repos/uber/pyro/pulls/1060/comments","review_comment_url":"https://api.github.com/repos/uber/pyro/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uber/pyro/issues/1060/comments","statuses_url":"https://api.github.com/repos/uber/pyro/statuses/643739495ba0030634c96ab5b8c9a2cd21e1bbac","head":{"label":"uber:remove-active-params","ref":"remove-active-params","sha":"643739495ba0030634c96ab5b8c9a2cd21e1bbac","user":{"login":"uber","id":538264,"avatar_url":"https://avatars3.githubusercontent.com/u/538264?v=4","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":94506832,"name":"pyro","full_name":"uber/pyro","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars3.githubusercontent.com/u/538264?v=4","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/pyro","description":"Deep universal probabilistic programming with Python and PyTorch","fork":false,"url":"https://api.github.com/repos/uber/pyro","forks_url":"https://api.github.com/repos/uber/pyro/forks","keys_url":"https://api.github.com/repos/uber/pyro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/pyro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/pyro/teams","hooks_url":"https://api.github.com/repos/uber/pyro/hooks","issue_events_url":"https://api.github.com/repos/uber/pyro/issues/events{/number}","events_url":"https://api.github.com/repos/uber/pyro/events","assignees_url":"https://api.github.com/repos/uber/pyro/assignees{/user}","branches_url":"https://api.github.com/repos/uber/pyro/branches{/branch}","tags_url":"https://api.github.com/repos/uber/pyro/tags","blobs_url":"https://api.github.com/repos/uber/pyro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/pyro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/pyro/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/pyro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/pyro/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/pyro/languages","stargazers_url":"https://api.github.com/repos/uber/pyro/stargazers","contributors_url":"https://api.github.com/repos/uber/pyro/contributors","subscribers_url":"https://api.github.com/repos/uber/pyro/subscribers","subscription_url":"https://api.github.com/repos/uber/pyro/subscription","commits_url":"https://api.github.com/repos/uber/pyro/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/pyro/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/pyro/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/pyro/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/pyro/contents/{+path}","compare_url":"https://api.github.com/repos/uber/pyro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/pyro/merges","archive_url":"https://api.github.com/repos/uber/pyro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/pyro/downloads","issues_url":"https://api.github.com/repos/uber/pyro/issues{/number}","pulls_url":"https://api.github.com/repos/uber/pyro/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/pyro/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/pyro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/pyro/labels{/name}","releases_url":"https://api.github.com/repos/uber/pyro/releases{/id}","deployments_url":"https://api.github.com/repos/uber/pyro/deployments","created_at":"2017-06-16T05:03:47Z","updated_at":"2018-04-23T02:20:06Z","pushed_at":"2018-04-23T02:20:03Z","git_url":"git://github.com/uber/pyro.git","ssh_url":"git@github.com:uber/pyro.git","clone_url":"https://github.com/uber/pyro.git","svn_url":"https://github.com/uber/pyro","homepage":"http://pyro.ai","size":55651,"stargazers_count":3278,"watchers_count":3278,"language":"Jupyter Notebook","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":333,"mirror_url":null,"archived":false,"open_issues_count":68,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":333,"open_issues":68,"watchers":3278,"default_branch":"dev"}},"base":{"label":"uber:dev","ref":"dev","sha":"582c55f1842f0e41d350e46399b69f0aaa38a9ec","user":{"login":"uber","id":538264,"avatar_url":"https://avatars3.githubusercontent.com/u/538264?v=4","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":94506832,"name":"pyro","full_name":"uber/pyro","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars3.githubusercontent.com/u/538264?v=4","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/pyro","description":"Deep universal probabilistic programming with Python and PyTorch","fork":false,"url":"https://api.github.com/repos/uber/pyro","forks_url":"https://api.github.com/repos/uber/pyro/forks","keys_url":"https://api.github.com/repos/uber/pyro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/pyro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/pyro/teams","hooks_url":"https://api.github.com/repos/uber/pyro/hooks","issue_events_url":"https://api.github.com/repos/uber/pyro/issues/events{/number}","events_url":"https://api.github.com/repos/uber/pyro/events","assignees_url":"https://api.github.com/repos/uber/pyro/assignees{/user}","branches_url":"https://api.github.com/repos/uber/pyro/branches{/branch}","tags_url":"https://api.github.com/repos/uber/pyro/tags","blobs_url":"https://api.github.com/repos/uber/pyro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/pyro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/pyro/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/pyro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/pyro/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/pyro/languages","stargazers_url":"https://api.github.com/repos/uber/pyro/stargazers","contributors_url":"https://api.github.com/repos/uber/pyro/contributors","subscribers_url":"https://api.github.com/repos/uber/pyro/subscribers","subscription_url":"https://api.github.com/repos/uber/pyro/subscription","commits_url":"https://api.github.com/repos/uber/pyro/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/pyro/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/pyro/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/pyro/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/pyro/contents/{+path}","compare_url":"https://api.github.com/repos/uber/pyro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/pyro/merges","archive_url":"https://api.github.com/repos/uber/pyro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/pyro/downloads","issues_url":"https://api.github.com/repos/uber/pyro/issues{/number}","pulls_url":"https://api.github.com/repos/uber/pyro/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/pyro/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/pyro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/pyro/labels{/name}","releases_url":"https://api.github.com/repos/uber/pyro/releases{/id}","deployments_url":"https://api.github.com/repos/uber/pyro/deployments","created_at":"2017-06-16T05:03:47Z","updated_at":"2018-04-23T02:20:06Z","pushed_at":"2018-04-23T02:20:03Z","git_url":"git://github.com/uber/pyro.git","ssh_url":"git@github.com:uber/pyro.git","clone_url":"https://github.com/uber/pyro.git","svn_url":"https://github.com/uber/pyro","homepage":"http://pyro.ai","size":55651,"stargazers_count":3278,"watchers_count":3278,"language":"Jupyter Notebook","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":333,"mirror_url":null,"archived":false,"open_issues_count":68,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":333,"open_issues":68,"watchers":3278,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/uber/pyro/pulls/1060"},"html":{"href":"https://github.com/uber/pyro/pull/1060"},"issue":{"href":"https://api.github.com/repos/uber/pyro/issues/1060"},"comments":{"href":"https://api.github.com/repos/uber/pyro/issues/1060/comments"},"review_comments":{"href":"https://api.github.com/repos/uber/pyro/pulls/1060/comments"},"review_comment":{"href":"https://api.github.com/repos/uber/pyro/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uber/pyro/pulls/1060/commits"},"statuses":{"href":"https://api.github.com/repos/uber/pyro/statuses/643739495ba0030634c96ab5b8c9a2cd21e1bbac"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"fritzo"}}