{"action":"created","comment":{"url":"https://api.github.com/repos/chainer/chainer/pulls/comments/199447924","pull_request_review_id":133566747,"id":199447924,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTQ0NzkyNA==","diff_hunk":"@@ -0,0 +1,229 @@\n+import unittest\n+\n+import numpy\n+\n+from chainer.backends import cuda\n+from chainer import functions\n+from chainer import gradient_check\n+from chainer import testing\n+from chainer.testing import backend\n+\n+\n+def _to_fcontiguous(arrays):\n+    xp = cuda.get_array_module(*arrays)\n+    return [xp.asfortranarray(a) for a in arrays]\n+\n+\n+def _decorrelated_batch_normalization(args):\n+    x, mean, projection, groups = args\n+    spatial_ndim = len(x.shape[2:])\n+    spatial_axis = tuple(range(2, 2 + spatial_ndim))\n+    b, c = x.shape[:2]\n+    g = groups\n+    C = c // g\n+\n+    x = x.reshape((b * g, C, ) + x.shape[2:])\n+    x_hat = x.transpose((1, 0) + spatial_axis).reshape((C, -1))\n+\n+    y_hat = projection.dot(x_hat - mean[:, None])\n+\n+    y = y_hat.reshape((C, b * g,) + x.shape[2:]).transpose(\n+        (1, 0) + spatial_axis)\n+    y = y.reshape((-1, c, ) + x.shape[2:])\n+    return y\n+\n+\n+def _calc_projection(x, mean, eps, groups):\n+    spatial_ndim = len(x.shape[2:])\n+    spatial_axis = tuple(range(2, 2 + spatial_ndim))\n+    b, c = x.shape[:2]\n+    g = groups\n+    C = c // g\n+    m = b * g\n+    for i in spatial_axis:\n+        m *= x.shape[i]\n+\n+    x = x.reshape((b * g, C, ) + x.shape[2:])\n+    x_hat = x.transpose((1, 0) + spatial_axis).reshape((C, -1))\n+\n+    mean = x_hat.mean(axis=1)\n+    x_hat = x_hat - mean[:, None]\n+\n+    cov = x_hat.dot(x_hat.T) / m + eps * numpy.eye(C, dtype=x.dtype)\n+    eigvals, eigvectors = numpy.linalg.eigh(cov)\n+    projection = eigvectors.dot(numpy.diag(eigvals ** -0.5)).dot(eigvectors.T)\n+    return projection\n+\n+\n+@testing.parameterize(*(testing.product({\n+    'n_channels': [8],\n+    'ndim': [0, 2],\n+    'groups': [1, 2],\n+    'eps': [2e-5, 5e-1],\n+    'dtype': [numpy.float32],\n+    'c_contiguous': [True, False],\n+}) + testing.product({\n+    'n_channels': [8],\n+    'ndim': [1],\n+    'groups': [1, 2],\n+    'eps': [2e-5, 5e-1],\n+    # NOTE(tommi): xp.linalg.eigh does not support float16","path":"tests/chainer_tests/functions_tests/normalization_tests/test_decorrelated_batch_normalization.py","position":70,"original_position":70,"commit_id":"5525c90b782368c57d60bc45cc9b2dfaa3387c8d","original_commit_id":"5525c90b782368c57d60bc45cc9b2dfaa3387c8d","user":{"login":"hvy","id":5983694,"node_id":"MDQ6VXNlcjU5ODM2OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5983694?v=4","gravatar_id":"","url":"https://api.github.com/users/hvy","html_url":"https://github.com/hvy","followers_url":"https://api.github.com/users/hvy/followers","following_url":"https://api.github.com/users/hvy/following{/other_user}","gists_url":"https://api.github.com/users/hvy/gists{/gist_id}","starred_url":"https://api.github.com/users/hvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvy/subscriptions","organizations_url":"https://api.github.com/users/hvy/orgs","repos_url":"https://api.github.com/users/hvy/repos","events_url":"https://api.github.com/users/hvy/events{/privacy}","received_events_url":"https://api.github.com/users/hvy/received_events","type":"User","site_admin":false},"body":"I think this comment applies to `np` but not `cp`?","created_at":"2018-07-02T10:11:40Z","updated_at":"2018-07-02T10:11:40Z","html_url":"https://github.com/chainer/chainer/pull/4686#discussion_r199447924","pull_request_url":"https://api.github.com/repos/chainer/chainer/pulls/4686","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/chainer/chainer/pulls/comments/199447924"},"html":{"href":"https://github.com/chainer/chainer/pull/4686#discussion_r199447924"},"pull_request":{"href":"https://api.github.com/repos/chainer/chainer/pulls/4686"}}},"pull_request":{"url":"https://api.github.com/repos/chainer/chainer/pulls/4686","id":184241171,"node_id":"MDExOlB1bGxSZXF1ZXN0MTg0MjQxMTcx","html_url":"https://github.com/chainer/chainer/pull/4686","diff_url":"https://github.com/chainer/chainer/pull/4686.diff","patch_url":"https://github.com/chainer/chainer/pull/4686.patch","issue_url":"https://api.github.com/repos/chainer/chainer/issues/4686","number":4686,"state":"open","locked":false,"title":"Add decorrelated batch normalization","user":{"login":"tkerola","id":3026734,"node_id":"MDQ6VXNlcjMwMjY3MzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/3026734?v=4","gravatar_id":"","url":"https://api.github.com/users/tkerola","html_url":"https://github.com/tkerola","followers_url":"https://api.github.com/users/tkerola/followers","following_url":"https://api.github.com/users/tkerola/following{/other_user}","gists_url":"https://api.github.com/users/tkerola/gists{/gist_id}","starred_url":"https://api.github.com/users/tkerola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkerola/subscriptions","organizations_url":"https://api.github.com/users/tkerola/orgs","repos_url":"https://api.github.com/users/tkerola/repos","events_url":"https://api.github.com/users/tkerola/events{/privacy}","received_events_url":"https://api.github.com/users/tkerola/received_events","type":"User","site_admin":false},"body":"This PR adds a function and link for decorrelated batch normalization (CVPR 2018): https://arxiv.org/abs/1804.08450\r\n\r\n\r\n- [x] Forward and backward tests pass.\r\n- [x] Implement group whitening (cf. the paper)\r\n- [x] Add documentation.\r\n\r\nThis does not implement double backward support nor backward support for `FixedDecorrelatedBatchNormalizationFunction`. I think it's better to leave them unimplemented for now, and add them in another PR.","created_at":"2018-04-26T06:48:28Z","updated_at":"2018-07-02T10:11:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b98545241d73f00c940222817d53f32d96125db","assignee":{"login":"hvy","id":5983694,"node_id":"MDQ6VXNlcjU5ODM2OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5983694?v=4","gravatar_id":"","url":"https://api.github.com/users/hvy","html_url":"https://github.com/hvy","followers_url":"https://api.github.com/users/hvy/followers","following_url":"https://api.github.com/users/hvy/following{/other_user}","gists_url":"https://api.github.com/users/hvy/gists{/gist_id}","starred_url":"https://api.github.com/users/hvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvy/subscriptions","organizations_url":"https://api.github.com/users/hvy/orgs","repos_url":"https://api.github.com/users/hvy/repos","events_url":"https://api.github.com/users/hvy/events{/privacy}","received_events_url":"https://api.github.com/users/hvy/received_events","type":"User","site_admin":false},"assignees":[{"login":"hvy","id":5983694,"node_id":"MDQ6VXNlcjU5ODM2OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5983694?v=4","gravatar_id":"","url":"https://api.github.com/users/hvy","html_url":"https://github.com/hvy","followers_url":"https://api.github.com/users/hvy/followers","following_url":"https://api.github.com/users/hvy/following{/other_user}","gists_url":"https://api.github.com/users/hvy/gists{/gist_id}","starred_url":"https://api.github.com/users/hvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvy/subscriptions","organizations_url":"https://api.github.com/users/hvy/orgs","repos_url":"https://api.github.com/users/hvy/repos","events_url":"https://api.github.com/users/hvy/events{/privacy}","received_events_url":"https://api.github.com/users/hvy/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/chainer/chainer/pulls/4686/commits","review_comments_url":"https://api.github.com/repos/chainer/chainer/pulls/4686/comments","review_comment_url":"https://api.github.com/repos/chainer/chainer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chainer/chainer/issues/4686/comments","statuses_url":"https://api.github.com/repos/chainer/chainer/statuses/5525c90b782368c57d60bc45cc9b2dfaa3387c8d","head":{"label":"tkerola:decorrelated_bn","ref":"decorrelated_bn","sha":"5525c90b782368c57d60bc45cc9b2dfaa3387c8d","user":{"login":"tkerola","id":3026734,"node_id":"MDQ6VXNlcjMwMjY3MzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/3026734?v=4","gravatar_id":"","url":"https://api.github.com/users/tkerola","html_url":"https://github.com/tkerola","followers_url":"https://api.github.com/users/tkerola/followers","following_url":"https://api.github.com/users/tkerola/following{/other_user}","gists_url":"https://api.github.com/users/tkerola/gists{/gist_id}","starred_url":"https://api.github.com/users/tkerola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkerola/subscriptions","organizations_url":"https://api.github.com/users/tkerola/orgs","repos_url":"https://api.github.com/users/tkerola/repos","events_url":"https://api.github.com/users/tkerola/events{/privacy}","received_events_url":"https://api.github.com/users/tkerola/received_events","type":"User","site_admin":false},"repo":{"id":80601569,"node_id":"MDEwOlJlcG9zaXRvcnk4MDYwMTU2OQ==","name":"chainer","full_name":"tkerola/chainer","owner":{"login":"tkerola","id":3026734,"node_id":"MDQ6VXNlcjMwMjY3MzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/3026734?v=4","gravatar_id":"","url":"https://api.github.com/users/tkerola","html_url":"https://github.com/tkerola","followers_url":"https://api.github.com/users/tkerola/followers","following_url":"https://api.github.com/users/tkerola/following{/other_user}","gists_url":"https://api.github.com/users/tkerola/gists{/gist_id}","starred_url":"https://api.github.com/users/tkerola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkerola/subscriptions","organizations_url":"https://api.github.com/users/tkerola/orgs","repos_url":"https://api.github.com/users/tkerola/repos","events_url":"https://api.github.com/users/tkerola/events{/privacy}","received_events_url":"https://api.github.com/users/tkerola/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tkerola/chainer","description":"A flexible framework of neural networks for deep learning","fork":true,"url":"https://api.github.com/repos/tkerola/chainer","forks_url":"https://api.github.com/repos/tkerola/chainer/forks","keys_url":"https://api.github.com/repos/tkerola/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tkerola/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tkerola/chainer/teams","hooks_url":"https://api.github.com/repos/tkerola/chainer/hooks","issue_events_url":"https://api.github.com/repos/tkerola/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/tkerola/chainer/events","assignees_url":"https://api.github.com/repos/tkerola/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/tkerola/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/tkerola/chainer/tags","blobs_url":"https://api.github.com/repos/tkerola/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tkerola/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tkerola/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/tkerola/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tkerola/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/tkerola/chainer/languages","stargazers_url":"https://api.github.com/repos/tkerola/chainer/stargazers","contributors_url":"https://api.github.com/repos/tkerola/chainer/contributors","subscribers_url":"https://api.github.com/repos/tkerola/chainer/subscribers","subscription_url":"https://api.github.com/repos/tkerola/chainer/subscription","commits_url":"https://api.github.com/repos/tkerola/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/tkerola/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/tkerola/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/tkerola/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/tkerola/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/tkerola/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tkerola/chainer/merges","archive_url":"https://api.github.com/repos/tkerola/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tkerola/chainer/downloads","issues_url":"https://api.github.com/repos/tkerola/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/tkerola/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/tkerola/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/tkerola/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tkerola/chainer/labels{/name}","releases_url":"https://api.github.com/repos/tkerola/chainer/releases{/id}","deployments_url":"https://api.github.com/repos/tkerola/chainer/deployments","created_at":"2017-02-01T08:28:18Z","updated_at":"2018-04-26T06:00:57Z","pushed_at":"2018-06-05T11:37:17Z","git_url":"git://github.com/tkerola/chainer.git","ssh_url":"git@github.com:tkerola/chainer.git","clone_url":"https://github.com/tkerola/chainer.git","svn_url":"https://github.com/tkerola/chainer","homepage":"http://chainer.org","size":23296,"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":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"chainer:master","ref":"master","sha":"f01b44c0e9963ff3aa03718a58efadc2ce93200e","user":{"login":"chainer","id":23183003,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzMTgzMDAz","avatar_url":"https://avatars3.githubusercontent.com/u/23183003?v=4","gravatar_id":"","url":"https://api.github.com/users/chainer","html_url":"https://github.com/chainer","followers_url":"https://api.github.com/users/chainer/followers","following_url":"https://api.github.com/users/chainer/following{/other_user}","gists_url":"https://api.github.com/users/chainer/gists{/gist_id}","starred_url":"https://api.github.com/users/chainer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chainer/subscriptions","organizations_url":"https://api.github.com/users/chainer/orgs","repos_url":"https://api.github.com/users/chainer/repos","events_url":"https://api.github.com/users/chainer/events{/privacy}","received_events_url":"https://api.github.com/users/chainer/received_events","type":"Organization","site_admin":false},"repo":{"id":36914478,"node_id":"MDEwOlJlcG9zaXRvcnkzNjkxNDQ3OA==","name":"chainer","full_name":"chainer/chainer","owner":{"login":"chainer","id":23183003,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzMTgzMDAz","avatar_url":"https://avatars3.githubusercontent.com/u/23183003?v=4","gravatar_id":"","url":"https://api.github.com/users/chainer","html_url":"https://github.com/chainer","followers_url":"https://api.github.com/users/chainer/followers","following_url":"https://api.github.com/users/chainer/following{/other_user}","gists_url":"https://api.github.com/users/chainer/gists{/gist_id}","starred_url":"https://api.github.com/users/chainer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chainer/subscriptions","organizations_url":"https://api.github.com/users/chainer/orgs","repos_url":"https://api.github.com/users/chainer/repos","events_url":"https://api.github.com/users/chainer/events{/privacy}","received_events_url":"https://api.github.com/users/chainer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chainer/chainer","description":"A flexible framework of neural networks for deep learning","fork":false,"url":"https://api.github.com/repos/chainer/chainer","forks_url":"https://api.github.com/repos/chainer/chainer/forks","keys_url":"https://api.github.com/repos/chainer/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chainer/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chainer/chainer/teams","hooks_url":"https://api.github.com/repos/chainer/chainer/hooks","issue_events_url":"https://api.github.com/repos/chainer/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/chainer/chainer/events","assignees_url":"https://api.github.com/repos/chainer/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/chainer/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/chainer/chainer/tags","blobs_url":"https://api.github.com/repos/chainer/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chainer/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chainer/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/chainer/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chainer/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/chainer/chainer/languages","stargazers_url":"https://api.github.com/repos/chainer/chainer/stargazers","contributors_url":"https://api.github.com/repos/chainer/chainer/contributors","subscribers_url":"https://api.github.com/repos/chainer/chainer/subscribers","subscription_url":"https://api.github.com/repos/chainer/chainer/subscription","commits_url":"https://api.github.com/repos/chainer/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/chainer/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/chainer/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/chainer/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/chainer/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/chainer/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chainer/chainer/merges","archive_url":"https://api.github.com/repos/chainer/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chainer/chainer/downloads","issues_url":"https://api.github.com/repos/chainer/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/chainer/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/chainer/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/chainer/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chainer/chainer/labels{/name}","releases_url":"https://api.github.com/repos/chainer/chainer/releases{/id}","deployments_url":"https://api.github.com/repos/chainer/chainer/deployments","created_at":"2015-06-05T05:50:37Z","updated_at":"2018-07-02T05:58:31Z","pushed_at":"2018-07-02T09:04:31Z","git_url":"git://github.com/chainer/chainer.git","ssh_url":"git@github.com:chainer/chainer.git","clone_url":"https://github.com/chainer/chainer.git","svn_url":"https://github.com/chainer/chainer","homepage":"https://chainer.org","size":26521,"stargazers_count":3929,"watchers_count":3929,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1051,"mirror_url":null,"archived":false,"open_issues_count":201,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1051,"open_issues":201,"watchers":3929,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chainer/chainer/pulls/4686"},"html":{"href":"https://github.com/chainer/chainer/pull/4686"},"issue":{"href":"https://api.github.com/repos/chainer/chainer/issues/4686"},"comments":{"href":"https://api.github.com/repos/chainer/chainer/issues/4686/comments"},"review_comments":{"href":"https://api.github.com/repos/chainer/chainer/pulls/4686/comments"},"review_comment":{"href":"https://api.github.com/repos/chainer/chainer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chainer/chainer/pulls/4686/commits"},"statuses":{"href":"https://api.github.com/repos/chainer/chainer/statuses/5525c90b782368c57d60bc45cc9b2dfaa3387c8d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"hvy"}}