Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the epsilon parameter to the BatchNorm layer. (fix #303) #311

Merged
merged 2 commits into from
Mar 27, 2018

Conversation

cook
Copy link
Contributor

@cook cook commented Mar 27, 2018

Liking the layers MVN and InstanceNorm, add the epsilon to the BatchNorm layer as a parameter to avoid the possible zero-division error.

  • Making the default value of the eps to be 0.f is to compatible with the old version.

@@ -59,7 +60,7 @@ int BatchNorm::load_model(const ModelBin& mb)

for (int i=0; i<channels; i++)
{
float sqrt_var = sqrt(var_data[i]);
float sqrt_var = sqrt(var_data[i]) + eps;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eps should be added inside sqrt()
ref https://arxiv.org/abs/1502.03167

@nihui nihui merged commit 2e9da1b into Tencent:master Mar 27, 2018
@cook cook deleted the fix_issue_303 branch May 4, 2018 06:23
ghimiredhikura pushed a commit to ghimiredhikura/NCNNSFD that referenced this pull request Jul 26, 2020
…encent#311)

* Add the epsilon parameter to the BatchNorm layer. (fix Tencent#303)

* Move the eps into the sqrt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants