{"action":"created","comment":{"url":"https://api.github.com/repos/wandb/client/pulls/comments/226753653","pull_request_review_id":166643242,"id":226753653,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjc1MzY1Mw==","diff_hunk":"@@ -115,18 +158,359 @@ def from_keras(cls, model):\n         layers = model.layers\n         for i in range(len(layers)):\n             node = Node.from_keras(layers[i], relevant_nodes)\n-            graph.nodes.append(node)\n+            graph.add_node(node)\n+\n+        return graph\n \n+    @classmethod\n+    def hook_torch(cls, model, criterion=None):\n+        graph = cls(\"torch\")\n+        graph.hook_torch_modules(model, criterion)\n         return graph\n \n+    def create_forward_hook(self, name, modules):\n+        graph = self\n+\n+        def after_forward_hook(module, input, output):\n+            if id(module) in modules:\n+                return\n+            modules.add(id(module))\n+            if not isinstance(output, tuple):\n+                output = (output,)\n+            parameters = [(pname, list(param.size()))\n+                          for pname, param in module.named_parameters()]\n+            node = Node(\n+                id=id(module),\n+                name=name,\n+                class_name=str(module),\n+                output_shape=[list(o.shape) for o in output],\n+                parameters=parameters,\n+                num_parameters=[reduce(mul, size)\n+                                for (pname, size) in parameters]\n+            )\n+            graph.nodes_by_id[id(module)] = node\n+            for param in module.parameters():\n+                graph.nodes_by_id[id(param)] = node\n+            graph.add_node(node)\n+            if not graph.criterion_passed:\n+                graph.criterion = output[0].grad_fn\n+        return after_forward_hook\n+\n+    def hook_torch_modules(self, module, criterion=None, prefix=None):\n+        torch = util.get_module(\"torch\", \"Could not import torch\")\n+        hooks = []\n+        modules = set()\n+        layers = 0\n+        graph = self\n+        if criterion:\n+            graph.criterion = criterion\n+            graph.criterion_passed = True\n+\n+        for name, sub_module in module._modules.items():","path":"wandb/data_types.py","position":116,"original_position":116,"commit_id":"947e97cedcb199cd546f386c097d25b08ee9d350","original_commit_id":"947e97cedcb199cd546f386c097d25b08ee9d350","user":{"login":"adrianbg","id":66751,"node_id":"MDQ6VXNlcjY2NzUx","avatar_url":"https://avatars2.githubusercontent.com/u/66751?v=4","gravatar_id":"","url":"https://api.github.com/users/adrianbg","html_url":"https://github.com/adrianbg","followers_url":"https://api.github.com/users/adrianbg/followers","following_url":"https://api.github.com/users/adrianbg/following{/other_user}","gists_url":"https://api.github.com/users/adrianbg/gists{/gist_id}","starred_url":"https://api.github.com/users/adrianbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrianbg/subscriptions","organizations_url":"https://api.github.com/users/adrianbg/orgs","repos_url":"https://api.github.com/users/adrianbg/repos","events_url":"https://api.github.com/users/adrianbg/events{/privacy}","received_events_url":"https://api.github.com/users/adrianbg/received_events","type":"User","site_admin":false},"body":"Is this better than `module.named_children()`? Maybe works across versions?","created_at":"2018-10-19T19:12:13Z","updated_at":"2018-10-19T19:36:14Z","html_url":"https://github.com/wandb/client/pull/243#discussion_r226753653","pull_request_url":"https://api.github.com/repos/wandb/client/pulls/243","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/wandb/client/pulls/comments/226753653"},"html":{"href":"https://github.com/wandb/client/pull/243#discussion_r226753653"},"pull_request":{"href":"https://api.github.com/repos/wandb/client/pulls/243"}}},"pull_request":{"url":"https://api.github.com/repos/wandb/client/pulls/243","id":223685516,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzNjg1NTE2","html_url":"https://github.com/wandb/client/pull/243","diff_url":"https://github.com/wandb/client/pull/243.diff","patch_url":"https://github.com/wandb/client/pull/243.patch","issue_url":"https://api.github.com/repos/wandb/client/issues/243","number":243,"state":"open","locked":false,"title":"Task/pytorch conf","user":{"login":"vanpelt","id":17,"node_id":"MDQ6VXNlcjE3","avatar_url":"https://avatars1.githubusercontent.com/u/17?v=4","gravatar_id":"","url":"https://api.github.com/users/vanpelt","html_url":"https://github.com/vanpelt","followers_url":"https://api.github.com/users/vanpelt/followers","following_url":"https://api.github.com/users/vanpelt/following{/other_user}","gists_url":"https://api.github.com/users/vanpelt/gists{/gist_id}","starred_url":"https://api.github.com/users/vanpelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanpelt/subscriptions","organizations_url":"https://api.github.com/users/vanpelt/orgs","repos_url":"https://api.github.com/users/vanpelt/repos","events_url":"https://api.github.com/users/vanpelt/events{/privacy}","received_events_url":"https://api.github.com/users/vanpelt/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-10-17T17:12:47Z","updated_at":"2018-10-19T19:36:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f6abe3a653f65ccab2c785e258928bcbff08e92f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/wandb/client/pulls/243/commits","review_comments_url":"https://api.github.com/repos/wandb/client/pulls/243/comments","review_comment_url":"https://api.github.com/repos/wandb/client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wandb/client/issues/243/comments","statuses_url":"https://api.github.com/repos/wandb/client/statuses/947e97cedcb199cd546f386c097d25b08ee9d350","head":{"label":"wandb:task/pytorch-conf","ref":"task/pytorch-conf","sha":"947e97cedcb199cd546f386c097d25b08ee9d350","user":{"login":"wandb","id":26401354,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2NDAxMzU0","avatar_url":"https://avatars2.githubusercontent.com/u/26401354?v=4","gravatar_id":"","url":"https://api.github.com/users/wandb","html_url":"https://github.com/wandb","followers_url":"https://api.github.com/users/wandb/followers","following_url":"https://api.github.com/users/wandb/following{/other_user}","gists_url":"https://api.github.com/users/wandb/gists{/gist_id}","starred_url":"https://api.github.com/users/wandb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wandb/subscriptions","organizations_url":"https://api.github.com/users/wandb/orgs","repos_url":"https://api.github.com/users/wandb/repos","events_url":"https://api.github.com/users/wandb/events{/privacy}","received_events_url":"https://api.github.com/users/wandb/received_events","type":"Organization","site_admin":false},"repo":{"id":86031674,"node_id":"MDEwOlJlcG9zaXRvcnk4NjAzMTY3NA==","name":"client","full_name":"wandb/client","private":false,"owner":{"login":"wandb","id":26401354,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2NDAxMzU0","avatar_url":"https://avatars2.githubusercontent.com/u/26401354?v=4","gravatar_id":"","url":"https://api.github.com/users/wandb","html_url":"https://github.com/wandb","followers_url":"https://api.github.com/users/wandb/followers","following_url":"https://api.github.com/users/wandb/following{/other_user}","gists_url":"https://api.github.com/users/wandb/gists{/gist_id}","starred_url":"https://api.github.com/users/wandb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wandb/subscriptions","organizations_url":"https://api.github.com/users/wandb/orgs","repos_url":"https://api.github.com/users/wandb/repos","events_url":"https://api.github.com/users/wandb/events{/privacy}","received_events_url":"https://api.github.com/users/wandb/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/wandb/client","description":"The official cli and python API client for W&B","fork":false,"url":"https://api.github.com/repos/wandb/client","forks_url":"https://api.github.com/repos/wandb/client/forks","keys_url":"https://api.github.com/repos/wandb/client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wandb/client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wandb/client/teams","hooks_url":"https://api.github.com/repos/wandb/client/hooks","issue_events_url":"https://api.github.com/repos/wandb/client/issues/events{/number}","events_url":"https://api.github.com/repos/wandb/client/events","assignees_url":"https://api.github.com/repos/wandb/client/assignees{/user}","branches_url":"https://api.github.com/repos/wandb/client/branches{/branch}","tags_url":"https://api.github.com/repos/wandb/client/tags","blobs_url":"https://api.github.com/repos/wandb/client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wandb/client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wandb/client/git/refs{/sha}","trees_url":"https://api.github.com/repos/wandb/client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wandb/client/statuses/{sha}","languages_url":"https://api.github.com/repos/wandb/client/languages","stargazers_url":"https://api.github.com/repos/wandb/client/stargazers","contributors_url":"https://api.github.com/repos/wandb/client/contributors","subscribers_url":"https://api.github.com/repos/wandb/client/subscribers","subscription_url":"https://api.github.com/repos/wandb/client/subscription","commits_url":"https://api.github.com/repos/wandb/client/commits{/sha}","git_commits_url":"https://api.github.com/repos/wandb/client/git/commits{/sha}","comments_url":"https://api.github.com/repos/wandb/client/comments{/number}","issue_comment_url":"https://api.github.com/repos/wandb/client/issues/comments{/number}","contents_url":"https://api.github.com/repos/wandb/client/contents/{+path}","compare_url":"https://api.github.com/repos/wandb/client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wandb/client/merges","archive_url":"https://api.github.com/repos/wandb/client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wandb/client/downloads","issues_url":"https://api.github.com/repos/wandb/client/issues{/number}","pulls_url":"https://api.github.com/repos/wandb/client/pulls{/number}","milestones_url":"https://api.github.com/repos/wandb/client/milestones{/number}","notifications_url":"https://api.github.com/repos/wandb/client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wandb/client/labels{/name}","releases_url":"https://api.github.com/repos/wandb/client/releases{/id}","deployments_url":"https://api.github.com/repos/wandb/client/deployments","created_at":"2017-03-24T05:46:23Z","updated_at":"2018-10-17T17:10:22Z","pushed_at":"2018-10-19T18:06:14Z","git_url":"git://github.com/wandb/client.git","ssh_url":"git@github.com:wandb/client.git","clone_url":"https://github.com/wandb/client.git","svn_url":"https://github.com/wandb/client","homepage":"http://docs.wandb.com","size":16599,"stargazers_count":10,"watchers_count":10,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":17,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":4,"open_issues":17,"watchers":10,"default_branch":"master"}},"base":{"label":"wandb:master","ref":"master","sha":"dd2f03036a9181ab9304c5457889925fc423a30a","user":{"login":"wandb","id":26401354,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2NDAxMzU0","avatar_url":"https://avatars2.githubusercontent.com/u/26401354?v=4","gravatar_id":"","url":"https://api.github.com/users/wandb","html_url":"https://github.com/wandb","followers_url":"https://api.github.com/users/wandb/followers","following_url":"https://api.github.com/users/wandb/following{/other_user}","gists_url":"https://api.github.com/users/wandb/gists{/gist_id}","starred_url":"https://api.github.com/users/wandb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wandb/subscriptions","organizations_url":"https://api.github.com/users/wandb/orgs","repos_url":"https://api.github.com/users/wandb/repos","events_url":"https://api.github.com/users/wandb/events{/privacy}","received_events_url":"https://api.github.com/users/wandb/received_events","type":"Organization","site_admin":false},"repo":{"id":86031674,"node_id":"MDEwOlJlcG9zaXRvcnk4NjAzMTY3NA==","name":"client","full_name":"wandb/client","private":false,"owner":{"login":"wandb","id":26401354,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2NDAxMzU0","avatar_url":"https://avatars2.githubusercontent.com/u/26401354?v=4","gravatar_id":"","url":"https://api.github.com/users/wandb","html_url":"https://github.com/wandb","followers_url":"https://api.github.com/users/wandb/followers","following_url":"https://api.github.com/users/wandb/following{/other_user}","gists_url":"https://api.github.com/users/wandb/gists{/gist_id}","starred_url":"https://api.github.com/users/wandb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wandb/subscriptions","organizations_url":"https://api.github.com/users/wandb/orgs","repos_url":"https://api.github.com/users/wandb/repos","events_url":"https://api.github.com/users/wandb/events{/privacy}","received_events_url":"https://api.github.com/users/wandb/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/wandb/client","description":"The official cli and python API client for W&B","fork":false,"url":"https://api.github.com/repos/wandb/client","forks_url":"https://api.github.com/repos/wandb/client/forks","keys_url":"https://api.github.com/repos/wandb/client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wandb/client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wandb/client/teams","hooks_url":"https://api.github.com/repos/wandb/client/hooks","issue_events_url":"https://api.github.com/repos/wandb/client/issues/events{/number}","events_url":"https://api.github.com/repos/wandb/client/events","assignees_url":"https://api.github.com/repos/wandb/client/assignees{/user}","branches_url":"https://api.github.com/repos/wandb/client/branches{/branch}","tags_url":"https://api.github.com/repos/wandb/client/tags","blobs_url":"https://api.github.com/repos/wandb/client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wandb/client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wandb/client/git/refs{/sha}","trees_url":"https://api.github.com/repos/wandb/client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wandb/client/statuses/{sha}","languages_url":"https://api.github.com/repos/wandb/client/languages","stargazers_url":"https://api.github.com/repos/wandb/client/stargazers","contributors_url":"https://api.github.com/repos/wandb/client/contributors","subscribers_url":"https://api.github.com/repos/wandb/client/subscribers","subscription_url":"https://api.github.com/repos/wandb/client/subscription","commits_url":"https://api.github.com/repos/wandb/client/commits{/sha}","git_commits_url":"https://api.github.com/repos/wandb/client/git/commits{/sha}","comments_url":"https://api.github.com/repos/wandb/client/comments{/number}","issue_comment_url":"https://api.github.com/repos/wandb/client/issues/comments{/number}","contents_url":"https://api.github.com/repos/wandb/client/contents/{+path}","compare_url":"https://api.github.com/repos/wandb/client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wandb/client/merges","archive_url":"https://api.github.com/repos/wandb/client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wandb/client/downloads","issues_url":"https://api.github.com/repos/wandb/client/issues{/number}","pulls_url":"https://api.github.com/repos/wandb/client/pulls{/number}","milestones_url":"https://api.github.com/repos/wandb/client/milestones{/number}","notifications_url":"https://api.github.com/repos/wandb/client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wandb/client/labels{/name}","releases_url":"https://api.github.com/repos/wandb/client/releases{/id}","deployments_url":"https://api.github.com/repos/wandb/client/deployments","created_at":"2017-03-24T05:46:23Z","updated_at":"2018-10-17T17:10:22Z","pushed_at":"2018-10-19T18:06:14Z","git_url":"git://github.com/wandb/client.git","ssh_url":"git@github.com:wandb/client.git","clone_url":"https://github.com/wandb/client.git","svn_url":"https://github.com/wandb/client","homepage":"http://docs.wandb.com","size":16599,"stargazers_count":10,"watchers_count":10,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":17,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":4,"open_issues":17,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wandb/client/pulls/243"},"html":{"href":"https://github.com/wandb/client/pull/243"},"issue":{"href":"https://api.github.com/repos/wandb/client/issues/243"},"comments":{"href":"https://api.github.com/repos/wandb/client/issues/243/comments"},"review_comments":{"href":"https://api.github.com/repos/wandb/client/pulls/243/comments"},"review_comment":{"href":"https://api.github.com/repos/wandb/client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wandb/client/pulls/243/commits"},"statuses":{"href":"https://api.github.com/repos/wandb/client/statuses/947e97cedcb199cd546f386c097d25b08ee9d350"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"adrianbg"}}