{"action":"created","comment":{"url":"https://api.github.com/repos/pytorch/ignite/pulls/comments/235130457","pull_request_review_id":176926468,"id":235130457,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNTEzMDQ1Nw==","diff_hunk":"@@ -0,0 +1,33 @@\n+from __future__ import division\n+import torch\n+from ignite.exceptions import NotComputableError\n+from ignite.metrics.metric import Metric\n+import numpy as np\n+\n+\n+class GeometricMeanAbsoluteError(Metric):\n+    r\"\"\"\n+    Calculates the Geometric Mean Absolute Error.\n+    It has been proposed in `Botchkarev 2018`__.\n+    :math:`\\text{GMRAE} = \\sqrt[n]{\\prod_{j=1}^{\\n}{|A_j - P_j|}`\n+    Where, :math:`A_j` is the ground truth and :math:`P_j` is the predicted value.\n+    - `update` must receive output of the form `(y_pred, y)`.\n+    - `y` and `y_pred` must be of same shape.\n+    __ https://arxiv.org/abs/1809.03006\n+    \"\"\"\n+\n+    def reset(self):\n+        self._product_of_errors = 1.0\n+        self._num_examples = 0\n+\n+    def update(self, output):\n+        y_pred, y = output\n+        errors = torch.abs(y.view_as(y_pred) - y_pred)\n+        self._product_of_errors = self._product_of_errors * torch.prod(errors).item()\n+        self._num_examples += y.shape[0]\n+\n+    def compute(self):\n+        if self._num_examples == 0:\n+            raise NotComputableError('GeometricMeanAbsoluteError must have at'\n+                                     'least one example before it can be computed.')\n+        return np.power(self._product_of_errors, 1.0 / self._num_examples)","path":"ignite/contrib/metrics/regression/geometric_mean_absolute_error.py","position":33,"original_position":33,"commit_id":"945ba1ad9799a0727f09c29d2a888f2e5e5f3006","original_commit_id":"945ba1ad9799a0727f09c29d2a888f2e5e5f3006","user":{"login":"zasdfgbnm","id":1032377,"node_id":"MDQ6VXNlcjEwMzIzNzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1032377?v=4","gravatar_id":"","url":"https://api.github.com/users/zasdfgbnm","html_url":"https://github.com/zasdfgbnm","followers_url":"https://api.github.com/users/zasdfgbnm/followers","following_url":"https://api.github.com/users/zasdfgbnm/following{/other_user}","gists_url":"https://api.github.com/users/zasdfgbnm/gists{/gist_id}","starred_url":"https://api.github.com/users/zasdfgbnm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zasdfgbnm/subscriptions","organizations_url":"https://api.github.com/users/zasdfgbnm/orgs","repos_url":"https://api.github.com/users/zasdfgbnm/repos","events_url":"https://api.github.com/users/zasdfgbnm/events{/privacy}","received_events_url":"https://api.github.com/users/zasdfgbnm/received_events","type":"User","site_admin":false},"body":"I suggest to replace `np.power(a, b)` with `a ** b`, since numpy is not a dependency of ignite.","created_at":"2018-11-20T19:02:12Z","updated_at":"2018-11-20T19:08:30Z","html_url":"https://github.com/pytorch/ignite/pull/334#discussion_r235130457","pull_request_url":"https://api.github.com/repos/pytorch/ignite/pulls/334","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/pytorch/ignite/pulls/comments/235130457"},"html":{"href":"https://github.com/pytorch/ignite/pull/334#discussion_r235130457"},"pull_request":{"href":"https://api.github.com/repos/pytorch/ignite/pulls/334"}}},"pull_request":{"url":"https://api.github.com/repos/pytorch/ignite/pulls/334","id":231289574,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxMjg5NTc0","html_url":"https://github.com/pytorch/ignite/pull/334","diff_url":"https://github.com/pytorch/ignite/pull/334.diff","patch_url":"https://github.com/pytorch/ignite/pull/334.patch","issue_url":"https://api.github.com/repos/pytorch/ignite/issues/334","number":334,"state":"open","locked":false,"title":"Added D2 Regression Metrics","user":{"login":"anmolsjoshi","id":17307490,"node_id":"MDQ6VXNlcjE3MzA3NDkw","avatar_url":"https://avatars1.githubusercontent.com/u/17307490?v=4","gravatar_id":"","url":"https://api.github.com/users/anmolsjoshi","html_url":"https://github.com/anmolsjoshi","followers_url":"https://api.github.com/users/anmolsjoshi/followers","following_url":"https://api.github.com/users/anmolsjoshi/following{/other_user}","gists_url":"https://api.github.com/users/anmolsjoshi/gists{/gist_id}","starred_url":"https://api.github.com/users/anmolsjoshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anmolsjoshi/subscriptions","organizations_url":"https://api.github.com/users/anmolsjoshi/orgs","repos_url":"https://api.github.com/users/anmolsjoshi/repos","events_url":"https://api.github.com/users/anmolsjoshi/events{/privacy}","received_events_url":"https://api.github.com/users/anmolsjoshi/received_events","type":"User","site_admin":false},"body":"Related to #307 \r\n\r\nDescription:\r\n* Canberra Metric\r\n* Fractional Absolute Error\r\n* Wave Hedges Distance\r\n* Geometric Mean Absolute Error\r\n* Geometric Mean Relative Absolute Error\r\n\r\nCheck list:\r\n* [x] New tests are added (if a new feature is modified)\r\n* [x] New doc strings: text and/or example code are in RST format\r\n* [x] Documentation is updated (if required)\r\n","created_at":"2018-11-15T18:18:56Z","updated_at":"2018-11-20T19:08:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"792de135e01a7874bf41944410b259aa67c1de82","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pytorch/ignite/pulls/334/commits","review_comments_url":"https://api.github.com/repos/pytorch/ignite/pulls/334/comments","review_comment_url":"https://api.github.com/repos/pytorch/ignite/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pytorch/ignite/issues/334/comments","statuses_url":"https://api.github.com/repos/pytorch/ignite/statuses/945ba1ad9799a0727f09c29d2a888f2e5e5f3006","head":{"label":"anmolsjoshi:d2metrics","ref":"d2metrics","sha":"945ba1ad9799a0727f09c29d2a888f2e5e5f3006","user":{"login":"anmolsjoshi","id":17307490,"node_id":"MDQ6VXNlcjE3MzA3NDkw","avatar_url":"https://avatars1.githubusercontent.com/u/17307490?v=4","gravatar_id":"","url":"https://api.github.com/users/anmolsjoshi","html_url":"https://github.com/anmolsjoshi","followers_url":"https://api.github.com/users/anmolsjoshi/followers","following_url":"https://api.github.com/users/anmolsjoshi/following{/other_user}","gists_url":"https://api.github.com/users/anmolsjoshi/gists{/gist_id}","starred_url":"https://api.github.com/users/anmolsjoshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anmolsjoshi/subscriptions","organizations_url":"https://api.github.com/users/anmolsjoshi/orgs","repos_url":"https://api.github.com/users/anmolsjoshi/repos","events_url":"https://api.github.com/users/anmolsjoshi/events{/privacy}","received_events_url":"https://api.github.com/users/anmolsjoshi/received_events","type":"User","site_admin":false},"repo":{"id":145067523,"node_id":"MDEwOlJlcG9zaXRvcnkxNDUwNjc1MjM=","name":"ignite","full_name":"anmolsjoshi/ignite","private":false,"owner":{"login":"anmolsjoshi","id":17307490,"node_id":"MDQ6VXNlcjE3MzA3NDkw","avatar_url":"https://avatars1.githubusercontent.com/u/17307490?v=4","gravatar_id":"","url":"https://api.github.com/users/anmolsjoshi","html_url":"https://github.com/anmolsjoshi","followers_url":"https://api.github.com/users/anmolsjoshi/followers","following_url":"https://api.github.com/users/anmolsjoshi/following{/other_user}","gists_url":"https://api.github.com/users/anmolsjoshi/gists{/gist_id}","starred_url":"https://api.github.com/users/anmolsjoshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anmolsjoshi/subscriptions","organizations_url":"https://api.github.com/users/anmolsjoshi/orgs","repos_url":"https://api.github.com/users/anmolsjoshi/repos","events_url":"https://api.github.com/users/anmolsjoshi/events{/privacy}","received_events_url":"https://api.github.com/users/anmolsjoshi/received_events","type":"User","site_admin":false},"html_url":"https://github.com/anmolsjoshi/ignite","description":"High-level library to help with training neural networks in PyTorch","fork":true,"url":"https://api.github.com/repos/anmolsjoshi/ignite","forks_url":"https://api.github.com/repos/anmolsjoshi/ignite/forks","keys_url":"https://api.github.com/repos/anmolsjoshi/ignite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anmolsjoshi/ignite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anmolsjoshi/ignite/teams","hooks_url":"https://api.github.com/repos/anmolsjoshi/ignite/hooks","issue_events_url":"https://api.github.com/repos/anmolsjoshi/ignite/issues/events{/number}","events_url":"https://api.github.com/repos/anmolsjoshi/ignite/events","assignees_url":"https://api.github.com/repos/anmolsjoshi/ignite/assignees{/user}","branches_url":"https://api.github.com/repos/anmolsjoshi/ignite/branches{/branch}","tags_url":"https://api.github.com/repos/anmolsjoshi/ignite/tags","blobs_url":"https://api.github.com/repos/anmolsjoshi/ignite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anmolsjoshi/ignite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anmolsjoshi/ignite/git/refs{/sha}","trees_url":"https://api.github.com/repos/anmolsjoshi/ignite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anmolsjoshi/ignite/statuses/{sha}","languages_url":"https://api.github.com/repos/anmolsjoshi/ignite/languages","stargazers_url":"https://api.github.com/repos/anmolsjoshi/ignite/stargazers","contributors_url":"https://api.github.com/repos/anmolsjoshi/ignite/contributors","subscribers_url":"https://api.github.com/repos/anmolsjoshi/ignite/subscribers","subscription_url":"https://api.github.com/repos/anmolsjoshi/ignite/subscription","commits_url":"https://api.github.com/repos/anmolsjoshi/ignite/commits{/sha}","git_commits_url":"https://api.github.com/repos/anmolsjoshi/ignite/git/commits{/sha}","comments_url":"https://api.github.com/repos/anmolsjoshi/ignite/comments{/number}","issue_comment_url":"https://api.github.com/repos/anmolsjoshi/ignite/issues/comments{/number}","contents_url":"https://api.github.com/repos/anmolsjoshi/ignite/contents/{+path}","compare_url":"https://api.github.com/repos/anmolsjoshi/ignite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anmolsjoshi/ignite/merges","archive_url":"https://api.github.com/repos/anmolsjoshi/ignite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anmolsjoshi/ignite/downloads","issues_url":"https://api.github.com/repos/anmolsjoshi/ignite/issues{/number}","pulls_url":"https://api.github.com/repos/anmolsjoshi/ignite/pulls{/number}","milestones_url":"https://api.github.com/repos/anmolsjoshi/ignite/milestones{/number}","notifications_url":"https://api.github.com/repos/anmolsjoshi/ignite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anmolsjoshi/ignite/labels{/name}","releases_url":"https://api.github.com/repos/anmolsjoshi/ignite/releases{/id}","deployments_url":"https://api.github.com/repos/anmolsjoshi/ignite/deployments","created_at":"2018-08-17T03:31:32Z","updated_at":"2018-11-07T21:52:45Z","pushed_at":"2018-11-20T08:38:54Z","git_url":"git://github.com/anmolsjoshi/ignite.git","ssh_url":"git@github.com:anmolsjoshi/ignite.git","clone_url":"https://github.com/anmolsjoshi/ignite.git","svn_url":"https://github.com/anmolsjoshi/ignite","homepage":"https://pytorch.org/ignite","size":30097,"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":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pytorch:master","ref":"master","sha":"9748defd7ba19d56e1e4f1e6c87cabc1e331bfef","user":{"login":"pytorch","id":21003710,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMDAzNzEw","avatar_url":"https://avatars3.githubusercontent.com/u/21003710?v=4","gravatar_id":"","url":"https://api.github.com/users/pytorch","html_url":"https://github.com/pytorch","followers_url":"https://api.github.com/users/pytorch/followers","following_url":"https://api.github.com/users/pytorch/following{/other_user}","gists_url":"https://api.github.com/users/pytorch/gists{/gist_id}","starred_url":"https://api.github.com/users/pytorch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pytorch/subscriptions","organizations_url":"https://api.github.com/users/pytorch/orgs","repos_url":"https://api.github.com/users/pytorch/repos","events_url":"https://api.github.com/users/pytorch/events{/privacy}","received_events_url":"https://api.github.com/users/pytorch/received_events","type":"Organization","site_admin":false},"repo":{"id":111835796,"node_id":"MDEwOlJlcG9zaXRvcnkxMTE4MzU3OTY=","name":"ignite","full_name":"pytorch/ignite","private":false,"owner":{"login":"pytorch","id":21003710,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxMDAzNzEw","avatar_url":"https://avatars3.githubusercontent.com/u/21003710?v=4","gravatar_id":"","url":"https://api.github.com/users/pytorch","html_url":"https://github.com/pytorch","followers_url":"https://api.github.com/users/pytorch/followers","following_url":"https://api.github.com/users/pytorch/following{/other_user}","gists_url":"https://api.github.com/users/pytorch/gists{/gist_id}","starred_url":"https://api.github.com/users/pytorch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pytorch/subscriptions","organizations_url":"https://api.github.com/users/pytorch/orgs","repos_url":"https://api.github.com/users/pytorch/repos","events_url":"https://api.github.com/users/pytorch/events{/privacy}","received_events_url":"https://api.github.com/users/pytorch/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pytorch/ignite","description":"High-level library to help with training neural networks in PyTorch","fork":false,"url":"https://api.github.com/repos/pytorch/ignite","forks_url":"https://api.github.com/repos/pytorch/ignite/forks","keys_url":"https://api.github.com/repos/pytorch/ignite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pytorch/ignite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pytorch/ignite/teams","hooks_url":"https://api.github.com/repos/pytorch/ignite/hooks","issue_events_url":"https://api.github.com/repos/pytorch/ignite/issues/events{/number}","events_url":"https://api.github.com/repos/pytorch/ignite/events","assignees_url":"https://api.github.com/repos/pytorch/ignite/assignees{/user}","branches_url":"https://api.github.com/repos/pytorch/ignite/branches{/branch}","tags_url":"https://api.github.com/repos/pytorch/ignite/tags","blobs_url":"https://api.github.com/repos/pytorch/ignite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pytorch/ignite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pytorch/ignite/git/refs{/sha}","trees_url":"https://api.github.com/repos/pytorch/ignite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pytorch/ignite/statuses/{sha}","languages_url":"https://api.github.com/repos/pytorch/ignite/languages","stargazers_url":"https://api.github.com/repos/pytorch/ignite/stargazers","contributors_url":"https://api.github.com/repos/pytorch/ignite/contributors","subscribers_url":"https://api.github.com/repos/pytorch/ignite/subscribers","subscription_url":"https://api.github.com/repos/pytorch/ignite/subscription","commits_url":"https://api.github.com/repos/pytorch/ignite/commits{/sha}","git_commits_url":"https://api.github.com/repos/pytorch/ignite/git/commits{/sha}","comments_url":"https://api.github.com/repos/pytorch/ignite/comments{/number}","issue_comment_url":"https://api.github.com/repos/pytorch/ignite/issues/comments{/number}","contents_url":"https://api.github.com/repos/pytorch/ignite/contents/{+path}","compare_url":"https://api.github.com/repos/pytorch/ignite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pytorch/ignite/merges","archive_url":"https://api.github.com/repos/pytorch/ignite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pytorch/ignite/downloads","issues_url":"https://api.github.com/repos/pytorch/ignite/issues{/number}","pulls_url":"https://api.github.com/repos/pytorch/ignite/pulls{/number}","milestones_url":"https://api.github.com/repos/pytorch/ignite/milestones{/number}","notifications_url":"https://api.github.com/repos/pytorch/ignite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pytorch/ignite/labels{/name}","releases_url":"https://api.github.com/repos/pytorch/ignite/releases{/id}","deployments_url":"https://api.github.com/repos/pytorch/ignite/deployments","created_at":"2017-11-23T17:31:21Z","updated_at":"2018-11-20T16:57:14Z","pushed_at":"2018-11-20T18:19:39Z","git_url":"git://github.com/pytorch/ignite.git","ssh_url":"git@github.com:pytorch/ignite.git","clone_url":"https://github.com/pytorch/ignite.git","svn_url":"https://github.com/pytorch/ignite","homepage":"https://pytorch.org/ignite","size":2421,"stargazers_count":984,"watchers_count":984,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":103,"mirror_url":null,"archived":false,"open_issues_count":27,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":103,"open_issues":27,"watchers":984,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytorch/ignite/pulls/334"},"html":{"href":"https://github.com/pytorch/ignite/pull/334"},"issue":{"href":"https://api.github.com/repos/pytorch/ignite/issues/334"},"comments":{"href":"https://api.github.com/repos/pytorch/ignite/issues/334/comments"},"review_comments":{"href":"https://api.github.com/repos/pytorch/ignite/pulls/334/comments"},"review_comment":{"href":"https://api.github.com/repos/pytorch/ignite/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pytorch/ignite/pulls/334/commits"},"statuses":{"href":"https://api.github.com/repos/pytorch/ignite/statuses/945ba1ad9799a0727f09c29d2a888f2e5e5f3006"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"zasdfgbnm"}}