{"action":"created","comment":{"url":"https://api.github.com/repos/tensorflow/minigo/pulls/comments/170490658","pull_request_review_id":99157212,"id":170490658,"diff_hunk":"@@ -321,58 +193,133 @@ def my_res_layer(inputs, train_mode):\n         my_conv2d(shared_output, filters=1, kernel_size=[1, 1]),\n         center=False, scale=False))\n     value_fc_hidden = tf.nn.relu(tf.layers.dense(\n-        tf.reshape(value_conv, [batch_size, go.N * go.N]),\n-        hparams['fc_width']))\n+        tf.reshape(value_conv, [-1, go.N * go.N]),\n+        params['fc_width']))\n     value_output = tf.nn.tanh(\n-        tf.reshape(tf.layers.dense(value_fc_hidden, 1), [batch_size]),\n+        tf.reshape(tf.layers.dense(value_fc_hidden, 1), [-1]),\n         name='value_output')\n-    return {\n-        'logits': logits,\n-        'policy_output': policy_output,\n-        'value_output': value_output,\n-    }\n \n-\n-def train_ops(input_tensors, output_tensors, **hparams):\n-    global_step = tf.Variable(0, name=\"global_step\", trainable=False)\n+    # train ops\n+    global_step = tf.train.get_or_create_global_step()\n     policy_cost = tf.reduce_mean(\n         tf.nn.softmax_cross_entropy_with_logits(\n-            logits=output_tensors['logits'],\n-            labels=input_tensors['pi_tensor']))\n-    value_cost = tf.reduce_mean(tf.square(\n-        output_tensors['value_output'] - input_tensors['value_tensor']))\n-    l2_cost = hparams['l2_strength'] * tf.add_n([tf.nn.l2_loss(v)\n-                                                 for v in tf.trainable_variables() if not 'bias' in v.name])\n+            logits=logits, labels=labels['pi_tensor']))\n+    value_cost = tf.reduce_mean(\n+        tf.square(value_output - labels['value_tensor']))\n+    l2_cost = params['l2_strength'] * tf.add_n([tf.nn.l2_loss(v)\n+        for v in tf.trainable_variables() if not 'bias' in v.name])\n     combined_cost = policy_cost + value_cost + l2_cost\n-    policy_output = output_tensors['policy_output']\n     policy_entropy = -tf.reduce_mean(tf.reduce_sum(\n         policy_output * tf.log(policy_output), axis=1))\n-    boundaries = list(map(int, [1e6, 2 * 1e6]))\n+    boundaries = [int(1e6), int(2e6)]\n     values = [1e-2, 1e-3, 1e-4]\n     learning_rate = tf.train.piecewise_constant(\n         global_step, boundaries, values)\n     update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)\n     with tf.control_dependencies(update_ops):\n         train_op = tf.train.MomentumOptimizer(\n-            learning_rate, hparams['momentum']).minimize(\n+            learning_rate, params['momentum']).minimize(\n                 combined_cost, global_step=global_step)\n \n-    return {\n-        'policy_cost': policy_cost,\n-        'value_cost': value_cost,\n-        'l2_cost': l2_cost,\n-        'combined_cost': combined_cost,\n-        'policy_entropy': policy_entropy,\n-        'global_step': global_step,\n-        'train_op': train_op,\n-    }\n-\n \n-def logging_ops():\n-    return tf.summary.merge([\n-        tf.summary.histogram(weight_var.name, weight_var)\n-        for weight_var in tf.trainable_variables()],\n-        name=\"weight_summaries\")\n+    metric_ops = {\n+        'accuracy': tf.metrics.accuracy(labels=labels['pi_tensor'],\n+                                        predictions=policy_output,\n+                                        name='accuracy_op'),\n+        'policy_cost': tf.metrics.mean(policy_cost),\n+        'value_cost': tf.metrics.mean(value_cost),\n+        'l2_cost': tf.metrics.mean(l2_cost),\n+        'policy_entropy': tf.metrics.mean(policy_entropy),\n+        'combined_cost': tf.metrics.mean(combined_cost),\n+    }\n+    # Register metrics as tf.summary to make them show up during training","path":"dual_net.py","position":null,"original_position":355,"commit_id":"ce4a9e4a2b8136f36489e77fb42cf5fb146860c8","original_commit_id":"ad0c7a11dee49a45993da5b6aee82d59f8bdb86e","user":{"login":"brilee","id":1320214,"avatar_url":"https://avatars2.githubusercontent.com/u/1320214?v=4","gravatar_id":"","url":"https://api.github.com/users/brilee","html_url":"https://github.com/brilee","followers_url":"https://api.github.com/users/brilee/followers","following_url":"https://api.github.com/users/brilee/following{/other_user}","gists_url":"https://api.github.com/users/brilee/gists{/gist_id}","starred_url":"https://api.github.com/users/brilee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brilee/subscriptions","organizations_url":"https://api.github.com/users/brilee/orgs","repos_url":"https://api.github.com/users/brilee/repos","events_url":"https://api.github.com/users/brilee/events{/privacy}","received_events_url":"https://api.github.com/users/brilee/received_events","type":"User","site_admin":false},"body":"comment added","created_at":"2018-02-26T04:09:17Z","updated_at":"2018-02-26T04:27:37Z","html_url":"https://github.com/tensorflow/minigo/pull/113#discussion_r170490658","pull_request_url":"https://api.github.com/repos/tensorflow/minigo/pulls/113","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/comments/170490658"},"html":{"href":"https://github.com/tensorflow/minigo/pull/113#discussion_r170490658"},"pull_request":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/113"}},"in_reply_to_id":170467741},"pull_request":{"url":"https://api.github.com/repos/tensorflow/minigo/pulls/113","id":171239012,"html_url":"https://github.com/tensorflow/minigo/pull/113","diff_url":"https://github.com/tensorflow/minigo/pull/113.diff","patch_url":"https://github.com/tensorflow/minigo/pull/113.patch","issue_url":"https://api.github.com/repos/tensorflow/minigo/issues/113","number":113,"state":"open","locked":false,"title":"Estimator rewrite","user":{"login":"brilee","id":1320214,"avatar_url":"https://avatars2.githubusercontent.com/u/1320214?v=4","gravatar_id":"","url":"https://api.github.com/users/brilee","html_url":"https://github.com/brilee","followers_url":"https://api.github.com/users/brilee/followers","following_url":"https://api.github.com/users/brilee/following{/other_user}","gists_url":"https://api.github.com/users/brilee/gists{/gist_id}","starred_url":"https://api.github.com/users/brilee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brilee/subscriptions","organizations_url":"https://api.github.com/users/brilee/orgs","repos_url":"https://api.github.com/users/brilee/repos","events_url":"https://api.github.com/users/brilee/events{/privacy}","received_events_url":"https://api.github.com/users/brilee/received_events","type":"User","site_admin":false},"body":"Estimator rewrite!\r\n\r\nRough outline: training occurs locally, with checkpointing happening automatically. After a fixed number of steps, as calculated by generation number, we take the latest exported checkpoint on disk and copy it to GCS, where the selfplay workers pick it up.\r\n\r\nAll logging is confirmed working, including a sessionrunhook to calculate update ratios. Apparently Estimator throws in a \"steps per second\" logger for free, too. Validation now has a nice framework under which to classify selfplay vs. pro dataset validation.\r\n\r\nThere's some continued hyperparameter ugliness; my next task will be to clean all this up.","created_at":"2018-02-25T16:45:25Z","updated_at":"2018-02-26T04:27:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be99b127bed08d4be915a2aa3cd56ca0ab1c3c42","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":832892684,"url":"https://api.github.com/repos/tensorflow/minigo/labels/size/XL","name":"size/XL","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/tensorflow/minigo/pulls/113/commits","review_comments_url":"https://api.github.com/repos/tensorflow/minigo/pulls/113/comments","review_comment_url":"https://api.github.com/repos/tensorflow/minigo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tensorflow/minigo/issues/113/comments","statuses_url":"https://api.github.com/repos/tensorflow/minigo/statuses/ce4a9e4a2b8136f36489e77fb42cf5fb146860c8","head":{"label":"brilee:estimator_rewrite","ref":"estimator_rewrite","sha":"ce4a9e4a2b8136f36489e77fb42cf5fb146860c8","user":{"login":"brilee","id":1320214,"avatar_url":"https://avatars2.githubusercontent.com/u/1320214?v=4","gravatar_id":"","url":"https://api.github.com/users/brilee","html_url":"https://github.com/brilee","followers_url":"https://api.github.com/users/brilee/followers","following_url":"https://api.github.com/users/brilee/following{/other_user}","gists_url":"https://api.github.com/users/brilee/gists{/gist_id}","starred_url":"https://api.github.com/users/brilee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brilee/subscriptions","organizations_url":"https://api.github.com/users/brilee/orgs","repos_url":"https://api.github.com/users/brilee/repos","events_url":"https://api.github.com/users/brilee/events{/privacy}","received_events_url":"https://api.github.com/users/brilee/received_events","type":"User","site_admin":false},"repo":{"id":120157364,"name":"minigo","full_name":"brilee/minigo","owner":{"login":"brilee","id":1320214,"avatar_url":"https://avatars2.githubusercontent.com/u/1320214?v=4","gravatar_id":"","url":"https://api.github.com/users/brilee","html_url":"https://github.com/brilee","followers_url":"https://api.github.com/users/brilee/followers","following_url":"https://api.github.com/users/brilee/following{/other_user}","gists_url":"https://api.github.com/users/brilee/gists{/gist_id}","starred_url":"https://api.github.com/users/brilee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brilee/subscriptions","organizations_url":"https://api.github.com/users/brilee/orgs","repos_url":"https://api.github.com/users/brilee/repos","events_url":"https://api.github.com/users/brilee/events{/privacy}","received_events_url":"https://api.github.com/users/brilee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brilee/minigo","description":"An open-source implementation of the AlphaGoZero algorithm","fork":true,"url":"https://api.github.com/repos/brilee/minigo","forks_url":"https://api.github.com/repos/brilee/minigo/forks","keys_url":"https://api.github.com/repos/brilee/minigo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brilee/minigo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brilee/minigo/teams","hooks_url":"https://api.github.com/repos/brilee/minigo/hooks","issue_events_url":"https://api.github.com/repos/brilee/minigo/issues/events{/number}","events_url":"https://api.github.com/repos/brilee/minigo/events","assignees_url":"https://api.github.com/repos/brilee/minigo/assignees{/user}","branches_url":"https://api.github.com/repos/brilee/minigo/branches{/branch}","tags_url":"https://api.github.com/repos/brilee/minigo/tags","blobs_url":"https://api.github.com/repos/brilee/minigo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brilee/minigo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brilee/minigo/git/refs{/sha}","trees_url":"https://api.github.com/repos/brilee/minigo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brilee/minigo/statuses/{sha}","languages_url":"https://api.github.com/repos/brilee/minigo/languages","stargazers_url":"https://api.github.com/repos/brilee/minigo/stargazers","contributors_url":"https://api.github.com/repos/brilee/minigo/contributors","subscribers_url":"https://api.github.com/repos/brilee/minigo/subscribers","subscription_url":"https://api.github.com/repos/brilee/minigo/subscription","commits_url":"https://api.github.com/repos/brilee/minigo/commits{/sha}","git_commits_url":"https://api.github.com/repos/brilee/minigo/git/commits{/sha}","comments_url":"https://api.github.com/repos/brilee/minigo/comments{/number}","issue_comment_url":"https://api.github.com/repos/brilee/minigo/issues/comments{/number}","contents_url":"https://api.github.com/repos/brilee/minigo/contents/{+path}","compare_url":"https://api.github.com/repos/brilee/minigo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brilee/minigo/merges","archive_url":"https://api.github.com/repos/brilee/minigo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brilee/minigo/downloads","issues_url":"https://api.github.com/repos/brilee/minigo/issues{/number}","pulls_url":"https://api.github.com/repos/brilee/minigo/pulls{/number}","milestones_url":"https://api.github.com/repos/brilee/minigo/milestones{/number}","notifications_url":"https://api.github.com/repos/brilee/minigo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brilee/minigo/labels{/name}","releases_url":"https://api.github.com/repos/brilee/minigo/releases{/id}","deployments_url":"https://api.github.com/repos/brilee/minigo/deployments","created_at":"2018-02-04T05:19:56Z","updated_at":"2018-02-04T05:19:58Z","pushed_at":"2018-02-26T04:27:15Z","git_url":"git://github.com/brilee/minigo.git","ssh_url":"git@github.com:brilee/minigo.git","clone_url":"https://github.com/brilee/minigo.git","svn_url":"https://github.com/brilee/minigo","homepage":"","size":478,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tensorflow:master","ref":"master","sha":"c391057cb3401951c9c9514e0f2c1828d9939acc","user":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars1.githubusercontent.com/u/15658638?v=4","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"repo":{"id":119455332,"name":"minigo","full_name":"tensorflow/minigo","owner":{"login":"tensorflow","id":15658638,"avatar_url":"https://avatars1.githubusercontent.com/u/15658638?v=4","gravatar_id":"","url":"https://api.github.com/users/tensorflow","html_url":"https://github.com/tensorflow","followers_url":"https://api.github.com/users/tensorflow/followers","following_url":"https://api.github.com/users/tensorflow/following{/other_user}","gists_url":"https://api.github.com/users/tensorflow/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflow/subscriptions","organizations_url":"https://api.github.com/users/tensorflow/orgs","repos_url":"https://api.github.com/users/tensorflow/repos","events_url":"https://api.github.com/users/tensorflow/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflow/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tensorflow/minigo","description":"An open-source implementation of the AlphaGoZero algorithm","fork":false,"url":"https://api.github.com/repos/tensorflow/minigo","forks_url":"https://api.github.com/repos/tensorflow/minigo/forks","keys_url":"https://api.github.com/repos/tensorflow/minigo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tensorflow/minigo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tensorflow/minigo/teams","hooks_url":"https://api.github.com/repos/tensorflow/minigo/hooks","issue_events_url":"https://api.github.com/repos/tensorflow/minigo/issues/events{/number}","events_url":"https://api.github.com/repos/tensorflow/minigo/events","assignees_url":"https://api.github.com/repos/tensorflow/minigo/assignees{/user}","branches_url":"https://api.github.com/repos/tensorflow/minigo/branches{/branch}","tags_url":"https://api.github.com/repos/tensorflow/minigo/tags","blobs_url":"https://api.github.com/repos/tensorflow/minigo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tensorflow/minigo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tensorflow/minigo/git/refs{/sha}","trees_url":"https://api.github.com/repos/tensorflow/minigo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tensorflow/minigo/statuses/{sha}","languages_url":"https://api.github.com/repos/tensorflow/minigo/languages","stargazers_url":"https://api.github.com/repos/tensorflow/minigo/stargazers","contributors_url":"https://api.github.com/repos/tensorflow/minigo/contributors","subscribers_url":"https://api.github.com/repos/tensorflow/minigo/subscribers","subscription_url":"https://api.github.com/repos/tensorflow/minigo/subscription","commits_url":"https://api.github.com/repos/tensorflow/minigo/commits{/sha}","git_commits_url":"https://api.github.com/repos/tensorflow/minigo/git/commits{/sha}","comments_url":"https://api.github.com/repos/tensorflow/minigo/comments{/number}","issue_comment_url":"https://api.github.com/repos/tensorflow/minigo/issues/comments{/number}","contents_url":"https://api.github.com/repos/tensorflow/minigo/contents/{+path}","compare_url":"https://api.github.com/repos/tensorflow/minigo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tensorflow/minigo/merges","archive_url":"https://api.github.com/repos/tensorflow/minigo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tensorflow/minigo/downloads","issues_url":"https://api.github.com/repos/tensorflow/minigo/issues{/number}","pulls_url":"https://api.github.com/repos/tensorflow/minigo/pulls{/number}","milestones_url":"https://api.github.com/repos/tensorflow/minigo/milestones{/number}","notifications_url":"https://api.github.com/repos/tensorflow/minigo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tensorflow/minigo/labels{/name}","releases_url":"https://api.github.com/repos/tensorflow/minigo/releases{/id}","deployments_url":"https://api.github.com/repos/tensorflow/minigo/deployments","created_at":"2018-01-29T23:29:07Z","updated_at":"2018-02-26T04:05:50Z","pushed_at":"2018-02-26T04:27:17Z","git_url":"git://github.com/tensorflow/minigo.git","ssh_url":"git@github.com:tensorflow/minigo.git","clone_url":"https://github.com/tensorflow/minigo.git","svn_url":"https://github.com/tensorflow/minigo","homepage":"","size":475,"stargazers_count":1727,"watchers_count":1727,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":194,"mirror_url":null,"archived":false,"open_issues_count":35,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":194,"open_issues":35,"watchers":1727,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/113"},"html":{"href":"https://github.com/tensorflow/minigo/pull/113"},"issue":{"href":"https://api.github.com/repos/tensorflow/minigo/issues/113"},"comments":{"href":"https://api.github.com/repos/tensorflow/minigo/issues/113/comments"},"review_comments":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/113/comments"},"review_comment":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tensorflow/minigo/pulls/113/commits"},"statuses":{"href":"https://api.github.com/repos/tensorflow/minigo/statuses/ce4a9e4a2b8136f36489e77fb42cf5fb146860c8"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"brilee"}}