{"action":"closed","issue":{"url":"https://api.github.com/repos/Tencent/ncnn/issues/303","repository_url":"https://api.github.com/repos/Tencent/ncnn","labels_url":"https://api.github.com/repos/Tencent/ncnn/issues/303/labels{/name}","comments_url":"https://api.github.com/repos/Tencent/ncnn/issues/303/comments","events_url":"https://api.github.com/repos/Tencent/ncnn/issues/303/events","html_url":"https://github.com/Tencent/ncnn/issues/303","id":307956027,"number":303,"title":"BatchNorm Layer: it seems to be safer to add a epsilon to the standard deviation","user":{"login":"cook","id":121121,"avatar_url":"https://avatars2.githubusercontent.com/u/121121?v=4","gravatar_id":"","url":"https://api.github.com/users/cook","html_url":"https://github.com/cook","followers_url":"https://api.github.com/users/cook/followers","following_url":"https://api.github.com/users/cook/following{/other_user}","gists_url":"https://api.github.com/users/cook/gists{/gist_id}","starred_url":"https://api.github.com/users/cook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cook/subscriptions","organizations_url":"https://api.github.com/users/cook/orgs","repos_url":"https://api.github.com/users/cook/repos","events_url":"https://api.github.com/users/cook/events{/privacy}","received_events_url":"https://api.github.com/users/cook/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-03-23T09:29:28Z","updated_at":"2018-03-27T05:57:10Z","closed_at":"2018-03-27T05:57:10Z","author_association":"NONE","body":"In the following codes cited from the file [src/layer/batchnorm](https://github.com/Tencent/ncnn/blob/6ea09ebf2c4cc05460a99dea53a6260f5843c19a/src/layer/batchnorm.cpp#L62), if the `sqrt_var` is zero, there will be a zero-division error. So I advice to add a epsilon to the standard deviation or add some protection codes.\r\n\r\n        float sqrt_var = sqrt(var_data[i]);\r\n        a_data[i] = bias_data[i] - slope_data[i] * mean_data[i] / sqrt_var;\r\n        b_data[i] = slope_data[i] / sqrt_var;\r\n\r\n(虽然可能性不大, 但加上去毕竟更安全些)"}}
{"actor":{"display_login":"nihui"}}