{"action":"created","comment":{"url":"https://api.github.com/repos/pfnet/chainer/pulls/comments/70011214","id":70011214,"diff_hunk":"@@ -0,0 +1,285 @@\n+import collections\n+import os\n+\n+import six\n+\n+from chainer import reporter as reporter_module\n+from chainer.training import extension as extension_module\n+from chainer.training import trigger as trigger_module\n+\n+\n+class _ExtensionEntry(object):\n+\n+    def __init__(self, extension, priority, trigger, invoke_before_training):\n+        self.extension = extension\n+        self.trigger = trigger\n+        self.invoke_before_training = invoke_before_training\n+        self.priority = priority\n+\n+\n+class Trainer(object):\n+\n+    \"\"\"The standard training loop in Chainer.\n+\n+    Trainer is an implementation of a training loop. Users can invoke the\n+    training by calling the :meth:`run` method.\n+\n+    Each iteration of the training loop proceeds as follows.\n+\n+    - Update of the parameters. It includes the mini-batch loading, forward\n+      and backward computations, and an execution of the update formula.\n+      These are all done by the update object held by the trainer.\n+    - Invocation of trainer extensions in the descending order of their\n+      priorities. A trigger object is attached to each extension, and it\n+      descides at each iteration whether the extension should be executed.\n+      Trigger objects are callable objects that take the trainer object as the\n+      argument and return a boolean value indicating whether the extension\n+      should be called or not.\n+\n+    Extensions are callable objects that take the trainer object as the\n+    argument. There are two ways to define custom extensions: inheriting the\n+    :class:`Extension` class, and decorating functions by\n+    :func:`make_extension`. See :class:`Extension` for more details on custom\n+    extensions.\n+\n+    Users can register extensions to the trainer by calling the :meth:`extend`\n+    method, where some configurations can be added.\n+\n+    - Trigger of an extension is a callable object that takes the trainer\n+      object as the argument, and is called at each iteration. It decides\n+      whether the extension should be executed at the iteration by returning a\n+      boolean value. In most cases, :class:`IntervalTrigger` is used, in which\n+      case users can simply specify a tuple of the interval length and its\n+      unit, like ``(1000, 'iteration')`` or ``(1, 'epoch')``.\n+    - The order of execution of extensions is determined by their priorities.\n+      Extensions of higher priorities are invoked earlier. There are three\n+      standard values for the priorities:\n+\n+      - ``PRIORITY_WRITER``. This is the priority for extensions that write\n+        some records to the :attr:`observation` dictionary. It includes cases\n+        that the extension directly adds values to the observation dictionary,\n+        or the extension uses the :func:`chainer.report` function to report\n+        values to the observation dictionary.\n+      - ``PRIORITY_EDITOR``. This is the priority for extensions that edit the\n+        :attr:`observation` dictionary based on already reported values.\n+      - ``PRIORITY_READER``. This is the priority for extensions that only read\n+        records from the :attr:`observation` dictionary. This is also suitable\n+        for extensions that do not use the :attr:`observation` dictionary at\n+        all.\n+\n+    - Extensions with ``invoke_before_training`` flag on are also invoked at\n+      the beginning of the training loop. Extensions that update the training","path":"chainer/training/trainer.py","position":69,"original_position":71,"commit_id":"342d53d19df8b71e9417e1566729f93f1bc62554","original_commit_id":"e7e1f16e1cb5fb3df4db8c4e3cdf349354d6fb36","user":{"login":"delta2323","id":407052,"avatar_url":"https://avatars.githubusercontent.com/u/407052?v=3","gravatar_id":"","url":"https://api.github.com/users/delta2323","html_url":"https://github.com/delta2323","followers_url":"https://api.github.com/users/delta2323/followers","following_url":"https://api.github.com/users/delta2323/following{/other_user}","gists_url":"https://api.github.com/users/delta2323/gists{/gist_id}","starred_url":"https://api.github.com/users/delta2323/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delta2323/subscriptions","organizations_url":"https://api.github.com/users/delta2323/orgs","repos_url":"https://api.github.com/users/delta2323/repos","events_url":"https://api.github.com/users/delta2323/events{/privacy}","received_events_url":"https://api.github.com/users/delta2323/received_events","type":"User","site_admin":false},"body":"OK, thanks.","created_at":"2016-07-08T00:37:43Z","updated_at":"2016-07-08T00:37:43Z","html_url":"https://github.com/pfnet/chainer/pull/1285#discussion_r70011214","pull_request_url":"https://api.github.com/repos/pfnet/chainer/pulls/1285","_links":{"self":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/comments/70011214"},"html":{"href":"https://github.com/pfnet/chainer/pull/1285#discussion_r70011214"},"pull_request":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/1285"}}},"pull_request":{"url":"https://api.github.com/repos/pfnet/chainer/pulls/1285","id":74042786,"html_url":"https://github.com/pfnet/chainer/pull/1285","diff_url":"https://github.com/pfnet/chainer/pull/1285.diff","patch_url":"https://github.com/pfnet/chainer/pull/1285.patch","issue_url":"https://api.github.com/repos/pfnet/chainer/issues/1285","number":1285,"state":"open","locked":false,"title":"Trainer2","user":{"login":"beam2d","id":392019,"avatar_url":"https://avatars.githubusercontent.com/u/392019?v=3","gravatar_id":"","url":"https://api.github.com/users/beam2d","html_url":"https://github.com/beam2d","followers_url":"https://api.github.com/users/beam2d/followers","following_url":"https://api.github.com/users/beam2d/following{/other_user}","gists_url":"https://api.github.com/users/beam2d/gists{/gist_id}","starred_url":"https://api.github.com/users/beam2d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beam2d/subscriptions","organizations_url":"https://api.github.com/users/beam2d/orgs","repos_url":"https://api.github.com/users/beam2d/repos","events_url":"https://api.github.com/users/beam2d/events{/privacy}","received_events_url":"https://api.github.com/users/beam2d/received_events","type":"User","site_admin":false},"body":"fix #914. I wrote an updated version of the training loop abstraction. This includes many improvements based on the feedback to the old version (#958). For example,\r\n\r\n- Design around the dataset abstraction is improved. Most considerable applications are supported with some efforts of customization.\r\n- New Trainer supports using multiple datasets and multiple optimizers.\r\n- Evaluation report is abstracted into Reporter object. This makes it easy to collect many observable values like loss/accuracy, activation statistics, etc.\r\n\r\nI have not updated the tutorial document yet, which should be done before merging it.","created_at":"2016-06-16T08:45:48Z","updated_at":"2016-07-08T00:37:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"676b32ea5a931de658790b748b49790beeda12ce","assignee":{"login":"delta2323","id":407052,"avatar_url":"https://avatars.githubusercontent.com/u/407052?v=3","gravatar_id":"","url":"https://api.github.com/users/delta2323","html_url":"https://github.com/delta2323","followers_url":"https://api.github.com/users/delta2323/followers","following_url":"https://api.github.com/users/delta2323/following{/other_user}","gists_url":"https://api.github.com/users/delta2323/gists{/gist_id}","starred_url":"https://api.github.com/users/delta2323/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delta2323/subscriptions","organizations_url":"https://api.github.com/users/delta2323/orgs","repos_url":"https://api.github.com/users/delta2323/repos","events_url":"https://api.github.com/users/delta2323/events{/privacy}","received_events_url":"https://api.github.com/users/delta2323/received_events","type":"User","site_admin":false},"assignees":[{"login":"delta2323","id":407052,"avatar_url":"https://avatars.githubusercontent.com/u/407052?v=3","gravatar_id":"","url":"https://api.github.com/users/delta2323","html_url":"https://github.com/delta2323","followers_url":"https://api.github.com/users/delta2323/followers","following_url":"https://api.github.com/users/delta2323/following{/other_user}","gists_url":"https://api.github.com/users/delta2323/gists{/gist_id}","starred_url":"https://api.github.com/users/delta2323/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delta2323/subscriptions","organizations_url":"https://api.github.com/users/delta2323/orgs","repos_url":"https://api.github.com/users/delta2323/repos","events_url":"https://api.github.com/users/delta2323/events{/privacy}","received_events_url":"https://api.github.com/users/delta2323/received_events","type":"User","site_admin":false},{"login":"unnonouno","id":740680,"avatar_url":"https://avatars.githubusercontent.com/u/740680?v=3","gravatar_id":"","url":"https://api.github.com/users/unnonouno","html_url":"https://github.com/unnonouno","followers_url":"https://api.github.com/users/unnonouno/followers","following_url":"https://api.github.com/users/unnonouno/following{/other_user}","gists_url":"https://api.github.com/users/unnonouno/gists{/gist_id}","starred_url":"https://api.github.com/users/unnonouno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unnonouno/subscriptions","organizations_url":"https://api.github.com/users/unnonouno/orgs","repos_url":"https://api.github.com/users/unnonouno/repos","events_url":"https://api.github.com/users/unnonouno/events{/privacy}","received_events_url":"https://api.github.com/users/unnonouno/received_events","type":"User","site_admin":false},{"login":"bkvogel","id":12666050,"avatar_url":"https://avatars.githubusercontent.com/u/12666050?v=3","gravatar_id":"","url":"https://api.github.com/users/bkvogel","html_url":"https://github.com/bkvogel","followers_url":"https://api.github.com/users/bkvogel/followers","following_url":"https://api.github.com/users/bkvogel/following{/other_user}","gists_url":"https://api.github.com/users/bkvogel/gists{/gist_id}","starred_url":"https://api.github.com/users/bkvogel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkvogel/subscriptions","organizations_url":"https://api.github.com/users/bkvogel/orgs","repos_url":"https://api.github.com/users/bkvogel/repos","events_url":"https://api.github.com/users/bkvogel/events{/privacy}","received_events_url":"https://api.github.com/users/bkvogel/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pfnet/chainer/pulls/1285/commits","review_comments_url":"https://api.github.com/repos/pfnet/chainer/pulls/1285/comments","review_comment_url":"https://api.github.com/repos/pfnet/chainer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pfnet/chainer/issues/1285/comments","statuses_url":"https://api.github.com/repos/pfnet/chainer/statuses/342d53d19df8b71e9417e1566729f93f1bc62554","head":{"label":"pfnet:trainer2","ref":"trainer2","sha":"342d53d19df8b71e9417e1566729f93f1bc62554","user":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"repo":{"id":36914478,"name":"chainer","full_name":"pfnet/chainer","owner":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pfnet/chainer","description":"A flexible framework of neural networks for deep learning","fork":false,"url":"https://api.github.com/repos/pfnet/chainer","forks_url":"https://api.github.com/repos/pfnet/chainer/forks","keys_url":"https://api.github.com/repos/pfnet/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pfnet/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pfnet/chainer/teams","hooks_url":"https://api.github.com/repos/pfnet/chainer/hooks","issue_events_url":"https://api.github.com/repos/pfnet/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/pfnet/chainer/events","assignees_url":"https://api.github.com/repos/pfnet/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/pfnet/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/pfnet/chainer/tags","blobs_url":"https://api.github.com/repos/pfnet/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pfnet/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pfnet/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/pfnet/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pfnet/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/pfnet/chainer/languages","stargazers_url":"https://api.github.com/repos/pfnet/chainer/stargazers","contributors_url":"https://api.github.com/repos/pfnet/chainer/contributors","subscribers_url":"https://api.github.com/repos/pfnet/chainer/subscribers","subscription_url":"https://api.github.com/repos/pfnet/chainer/subscription","commits_url":"https://api.github.com/repos/pfnet/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/pfnet/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/pfnet/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/pfnet/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/pfnet/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/pfnet/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pfnet/chainer/merges","archive_url":"https://api.github.com/repos/pfnet/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pfnet/chainer/downloads","issues_url":"https://api.github.com/repos/pfnet/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/pfnet/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/pfnet/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/pfnet/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pfnet/chainer/labels{/name}","releases_url":"https://api.github.com/repos/pfnet/chainer/releases{/id}","deployments_url":"https://api.github.com/repos/pfnet/chainer/deployments","created_at":"2015-06-05T05:50:37Z","updated_at":"2016-07-07T19:41:59Z","pushed_at":"2016-07-07T16:24:45Z","git_url":"git://github.com/pfnet/chainer.git","ssh_url":"git@github.com:pfnet/chainer.git","clone_url":"https://github.com/pfnet/chainer.git","svn_url":"https://github.com/pfnet/chainer","homepage":"http://chainer.org","size":23700,"stargazers_count":1489,"watchers_count":1489,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":348,"mirror_url":null,"open_issues_count":182,"forks":348,"open_issues":182,"watchers":1489,"default_branch":"master"}},"base":{"label":"pfnet:master","ref":"master","sha":"6a63b31b78fccf34c6357a0b9788a824aadc7a0a","user":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"repo":{"id":36914478,"name":"chainer","full_name":"pfnet/chainer","owner":{"login":"pfnet","id":9739572,"avatar_url":"https://avatars.githubusercontent.com/u/9739572?v=3","gravatar_id":"","url":"https://api.github.com/users/pfnet","html_url":"https://github.com/pfnet","followers_url":"https://api.github.com/users/pfnet/followers","following_url":"https://api.github.com/users/pfnet/following{/other_user}","gists_url":"https://api.github.com/users/pfnet/gists{/gist_id}","starred_url":"https://api.github.com/users/pfnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfnet/subscriptions","organizations_url":"https://api.github.com/users/pfnet/orgs","repos_url":"https://api.github.com/users/pfnet/repos","events_url":"https://api.github.com/users/pfnet/events{/privacy}","received_events_url":"https://api.github.com/users/pfnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pfnet/chainer","description":"A flexible framework of neural networks for deep learning","fork":false,"url":"https://api.github.com/repos/pfnet/chainer","forks_url":"https://api.github.com/repos/pfnet/chainer/forks","keys_url":"https://api.github.com/repos/pfnet/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pfnet/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pfnet/chainer/teams","hooks_url":"https://api.github.com/repos/pfnet/chainer/hooks","issue_events_url":"https://api.github.com/repos/pfnet/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/pfnet/chainer/events","assignees_url":"https://api.github.com/repos/pfnet/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/pfnet/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/pfnet/chainer/tags","blobs_url":"https://api.github.com/repos/pfnet/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pfnet/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pfnet/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/pfnet/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pfnet/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/pfnet/chainer/languages","stargazers_url":"https://api.github.com/repos/pfnet/chainer/stargazers","contributors_url":"https://api.github.com/repos/pfnet/chainer/contributors","subscribers_url":"https://api.github.com/repos/pfnet/chainer/subscribers","subscription_url":"https://api.github.com/repos/pfnet/chainer/subscription","commits_url":"https://api.github.com/repos/pfnet/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/pfnet/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/pfnet/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/pfnet/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/pfnet/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/pfnet/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pfnet/chainer/merges","archive_url":"https://api.github.com/repos/pfnet/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pfnet/chainer/downloads","issues_url":"https://api.github.com/repos/pfnet/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/pfnet/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/pfnet/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/pfnet/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pfnet/chainer/labels{/name}","releases_url":"https://api.github.com/repos/pfnet/chainer/releases{/id}","deployments_url":"https://api.github.com/repos/pfnet/chainer/deployments","created_at":"2015-06-05T05:50:37Z","updated_at":"2016-07-07T19:41:59Z","pushed_at":"2016-07-07T16:24:45Z","git_url":"git://github.com/pfnet/chainer.git","ssh_url":"git@github.com:pfnet/chainer.git","clone_url":"https://github.com/pfnet/chainer.git","svn_url":"https://github.com/pfnet/chainer","homepage":"http://chainer.org","size":23700,"stargazers_count":1489,"watchers_count":1489,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":348,"mirror_url":null,"open_issues_count":182,"forks":348,"open_issues":182,"watchers":1489,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/1285"},"html":{"href":"https://github.com/pfnet/chainer/pull/1285"},"issue":{"href":"https://api.github.com/repos/pfnet/chainer/issues/1285"},"comments":{"href":"https://api.github.com/repos/pfnet/chainer/issues/1285/comments"},"review_comments":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/1285/comments"},"review_comment":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pfnet/chainer/pulls/1285/commits"},"statuses":{"href":"https://api.github.com/repos/pfnet/chainer/statuses/342d53d19df8b71e9417e1566729f93f1bc62554"}}}}
{"actor":{"display_login":"delta2323"}}