1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Fix Batch Normalization layer imported from NVIDIA Caffe.

This commit is contained in:
Dmitry Kurtaev
2018-01-31 16:25:45 +03:00
parent f57630d92b
commit 844f1d0281
4 changed files with 420 additions and 342 deletions
+2
View File
@@ -672,6 +672,8 @@ message BatchNormParameter {
// Small value to add to the variance estimate so that we don't divide by
// zero.
optional float eps = 3 [default = 1e-5];
// It true, scale and add biases. Source: https://github.com/NVIDIA/caffe/
optional bool scale_bias = 7 [default = false];
}
message BiasParameter {
+4 -2
View File
@@ -32,6 +32,8 @@ public:
hasWeights = params.get<bool>("has_weight", false);
hasBias = params.get<bool>("has_bias", false);
if(params.get<bool>("scale_bias", false))
hasWeights = hasBias = true;
epsilon = params.get<float>("eps", 1E-5);
size_t n = blobs[0].total();
@@ -47,8 +49,8 @@ public:
varMeanScale = 1/varMeanScale;
}
const int weightsBlobIndex = 2;
const int biasBlobIndex = weightsBlobIndex + hasWeights;
const int biasBlobIndex = blobs.size() - 1;
const int weightsBlobIndex = biasBlobIndex - hasBias;
if( hasWeights )
{