{"action":"created","issue":{"url":"https://api.github.com/repos/chainer/chainer/issues/4663","repository_url":"https://api.github.com/repos/chainer/chainer","labels_url":"https://api.github.com/repos/chainer/chainer/issues/4663/labels{/name}","comments_url":"https://api.github.com/repos/chainer/chainer/issues/4663/comments","events_url":"https://api.github.com/repos/chainer/chainer/issues/4663/events","html_url":"https://github.com/chainer/chainer/pull/4663","id":315859265,"number":4663,"title":"Warn only if the BN input tensor is 2-dimensional","user":{"login":"tkerola","id":3026734,"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},"labels":[{"id":220754693,"url":"https://api.github.com/repos/chainer/chainer/labels/bug","name":"bug","color":"fc2929","default":true},{"id":619749531,"url":"https://api.github.com/repos/chainer/chainer/labels/to-be-backported","name":"to-be-backported","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":{"login":"kmaehashi","id":939877,"avatar_url":"https://avatars0.githubusercontent.com/u/939877?v=4","gravatar_id":"","url":"https://api.github.com/users/kmaehashi","html_url":"https://github.com/kmaehashi","followers_url":"https://api.github.com/users/kmaehashi/followers","following_url":"https://api.github.com/users/kmaehashi/following{/other_user}","gists_url":"https://api.github.com/users/kmaehashi/gists{/gist_id}","starred_url":"https://api.github.com/users/kmaehashi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmaehashi/subscriptions","organizations_url":"https://api.github.com/users/kmaehashi/orgs","repos_url":"https://api.github.com/users/kmaehashi/repos","events_url":"https://api.github.com/users/kmaehashi/events{/privacy}","received_events_url":"https://api.github.com/users/kmaehashi/received_events","type":"User","site_admin":false},"assignees":[{"login":"kmaehashi","id":939877,"avatar_url":"https://avatars0.githubusercontent.com/u/939877?v=4","gravatar_id":"","url":"https://api.github.com/users/kmaehashi","html_url":"https://github.com/kmaehashi","followers_url":"https://api.github.com/users/kmaehashi/followers","following_url":"https://api.github.com/users/kmaehashi/following{/other_user}","gists_url":"https://api.github.com/users/kmaehashi/gists{/gist_id}","starred_url":"https://api.github.com/users/kmaehashi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmaehashi/subscriptions","organizations_url":"https://api.github.com/users/kmaehashi/orgs","repos_url":"https://api.github.com/users/kmaehashi/repos","events_url":"https://api.github.com/users/kmaehashi/events{/privacy}","received_events_url":"https://api.github.com/users/kmaehashi/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-04-19T12:40:21Z","updated_at":"2018-04-23T04:28:06Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/chainer/chainer/pulls/4663","html_url":"https://github.com/chainer/chainer/pull/4663","diff_url":"https://github.com/chainer/chainer/pull/4663.diff","patch_url":"https://github.com/chainer/chainer/pull/4663.patch"},"body":"Fixes #4662.\r\n\r\nI fixed the false warning that appeared in #3996 when the input tensor has more than 2 dimensions. Note that this PR only fixes the standard case when `axis=None`. A more sophisticated check is needed to not give false warnings for the other axis options introduced in #4266.\r\n\r\nThe following illustrates the behavior due to this PR:\r\n```\r\nIn [1]: import numpy as np\r\n\r\nIn [2]: import chainer\r\n\r\nIn [3]: bn = chainer.links.BatchNormalization(4)\r\n\r\nIn [4]: x = np.random.rand(1, 4).astype(np.float32)\r\n\r\nIn [5]: bn(x)\r\n/home/tommi/.pyenv/versions/3.4.3/envs/chainer-dev3.4.3/lib/python3.4/site-packages/chainer-5.0.0a1-py3.4.egg/chainer/functions/normalization/batch_normalization.py:100: UserWarning: A batch with no more than one sample has been given to F.batch_normalization. F.batch_normalization will always output a zero tensor for such batches. This could be caused by incorrect configuration in your code (such as running evaluation while chainer.config.train=True), but could also happen in the last batch of training if non-repeating iterator is used.\r\n  UserWarning)\r\nOut[5]: variable([[ 0.,  0.,  0.,  0.]])\r\n\r\nIn [6]: x = np.random.rand(1, 4, 5, 6).astype(np.float32)\r\n\r\nIn [7]: bn(x)\r\nOut[7]: \r\nvariable([[[[ 0.88383329,  0.24783106, -0.35056776,  0.45682225,\r\n             -1.38407457, -0.39653379],\r\n            [-0.97899908, -1.57535398, -1.38358796, -1.27693629,\r\n             -2.20569324,  1.22138727],\r\n            [ 0.14362516,  1.36604619, -0.4590117 ,  1.38188398,\r\n             -0.74986064,  0.87933534],\r\n            [ 0.80834419, -0.79376137,  1.31242239, -0.29662037,\r\n             -0.34697992, -0.72915429],\r\n            [ 0.5668816 ,  0.69676024,  1.37218988,  0.01948533,\r\n              1.22701776,  0.34326702]],\r\n\r\n           [[ 0.0104244 ,  1.07958531,  0.40102562,  0.67557257,\r\n              0.8304196 ,  0.16076598],\r\n            [ 0.99945849, -1.11169207, -0.48962063, -1.03725564,\r\n              1.56631446,  0.33011672],\r\n            [-1.57883441,  1.61516035,  0.01796032, -0.55186921,\r\n             -1.66364145, -1.5349046 ],\r\n            [-0.28114355,  0.95056921, -1.64674163,  0.83853984,\r\n             -1.0257318 ,  1.12100112],\r\n            [-1.56099236,  0.22759983,  0.25137761,  1.24357152,\r\n             -0.04931128,  0.21227953]],\r\n\r\n           [[-1.93279457,  0.64842421,  0.81283778,  0.79755312,\r\n              0.31647423, -0.10959966],\r\n            [-0.39431885, -1.4173367 ,  0.52795428,  1.86794317,\r\n              0.3631916 , -0.34962398],\r\n            [-1.275949  , -1.08183765,  1.81970918, -1.66731   ,\r\n             -0.16015647,  0.36299735],\r\n            [ 0.97641951,  0.40229759,  0.53101915,  0.96606696,\r\n             -0.64821613,  0.00826658],\r\n            [ 0.7754072 , -1.11620092, -1.27183533, -0.00277958,\r\n              1.33899188, -1.08759546]],\r\n\r\n           [[-0.06503277, -0.78476042,  0.61540544,  1.42846644,\r\n             -1.09960437, -1.429672  ],\r\n            [-1.32273185,  1.62729824,  1.4065882 ,  0.27002716,\r\n             -1.22050107, -0.65235502],\r\n            [ 1.27065504, -0.62376803,  0.42506689, -0.64073187,\r\n             -1.28400862,  0.5179444 ],\r\n            [ 0.34610024, -0.22061768, -0.50182396, -1.0034554 ,\r\n             -0.81978297,  1.3319149 ],\r\n            [ 1.39201581,  1.34085441,  0.9786694 , -0.60437816,\r\n              0.57300836, -1.25078964]]]])\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/chainer/chainer/issues/comments/383451001","html_url":"https://github.com/chainer/chainer/pull/4663#issuecomment-383451001","issue_url":"https://api.github.com/repos/chainer/chainer/issues/4663","id":383451001,"user":{"login":"tkerola","id":3026734,"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},"created_at":"2018-04-23T04:28:06Z","updated_at":"2018-04-23T04:28:06Z","author_association":"CONTRIBUTOR","body":"@kmaehashi Thanks, I applied your suggested solution. I also separated the warning message into two cases, since it's not correct to tell the user that the batch has only one sample if axis 0 was not used in the BN statistics. How do you think about having two warnings like this?"}}
{"actor":{"display_login":"tkerola"}}