Skip to content

Commit d274d90

Browse files
authored
Fix a bug of arcface-mobilefacenet (wang-xinyu#562)
Fix a bug which can cause different output results from tensorrt and insightface(mxnet) arcface-mobilefacenet. Change the `eps` value of `BatchNorm2d` layer in `conv_bn_relu()`, `conv_bn()` and `DepthWise()` from `2e-5` to `1e-3` according to the origin mxnet implementation of mobilefacenet from insightface.
1 parent 31646b6 commit d274d90

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

arcface/arcface-mobilefacenet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ ILayer* conv_bn_relu(INetworkDefinition *network, std::map<std::string, Weights>
153153
conv1->setStrideNd(DimsHW{s, s});
154154
conv1->setPaddingNd(DimsHW{p, p});
155155
conv1->setNbGroups(groups);
156-
auto bn1 = addBatchNorm2d(network, weightMap, *conv1->getOutput(0), lname + "_batchnorm", 2e-5);
156+
auto bn1 = addBatchNorm2d(network, weightMap, *conv1->getOutput(0), lname + "_batchnorm", 1e-3);
157157
assert(bn1);
158158
auto act1 = addPRelu(network, weightMap, *bn1->getOutput(0), lname + "_relu");
159159
assert(act1);
@@ -167,7 +167,7 @@ ILayer* conv_bn(INetworkDefinition *network, std::map<std::string, Weights>& wei
167167
conv1->setStrideNd(DimsHW{s, s});
168168
conv1->setPaddingNd(DimsHW{p, p});
169169
conv1->setNbGroups(groups);
170-
auto bn1 = addBatchNorm2d(network, weightMap, *conv1->getOutput(0), lname + "_batchnorm", 2e-5);
170+
auto bn1 = addBatchNorm2d(network, weightMap, *conv1->getOutput(0), lname + "_batchnorm", 1e-3);
171171
assert(bn1);
172172
return bn1;
173173
}
@@ -179,7 +179,7 @@ ILayer* DepthWise(INetworkDefinition *network, std::map<std::string, Weights>& w
179179
conv1->setStrideNd(DimsHW{1, 1});
180180
conv1->setPaddingNd(DimsHW{0, 0});
181181
conv1->setNbGroups(1);
182-
auto bn1 = addBatchNorm2d(network, weightMap, *conv1->getOutput(0), lname + "_conv_sep_batchnorm", 2e-5);
182+
auto bn1 = addBatchNorm2d(network, weightMap, *conv1->getOutput(0), lname + "_conv_sep_batchnorm", 1e-3);
183183
assert(bn1);
184184
auto act1 = addPRelu(network, weightMap, *bn1->getOutput(0), lname + "_conv_sep_relu");
185185
assert(act1);
@@ -189,7 +189,7 @@ ILayer* DepthWise(INetworkDefinition *network, std::map<std::string, Weights>& w
189189
conv2->setStrideNd(DimsHW{s, s});
190190
conv2->setPaddingNd(DimsHW{1, 1});
191191
conv2->setNbGroups(groups);
192-
auto bn2 = addBatchNorm2d(network, weightMap, *conv2->getOutput(0), lname + "_conv_dw_batchnorm", 2e-5);
192+
auto bn2 = addBatchNorm2d(network, weightMap, *conv2->getOutput(0), lname + "_conv_dw_batchnorm", 1e-3);
193193
assert(bn2);
194194
auto act2 = addPRelu(network, weightMap, *bn2->getOutput(0), lname + "_conv_dw_relu");
195195
assert(act2);
@@ -199,7 +199,7 @@ ILayer* DepthWise(INetworkDefinition *network, std::map<std::string, Weights>& w
199199
conv3->setStrideNd(DimsHW{1, 1});
200200
conv3->setPaddingNd(DimsHW{0, 0});
201201
conv3->setNbGroups(1);
202-
auto bn3 = addBatchNorm2d(network, weightMap, *conv3->getOutput(0), lname + "_conv_proj_batchnorm", 2e-5);
202+
auto bn3 = addBatchNorm2d(network, weightMap, *conv3->getOutput(0), lname + "_conv_proj_batchnorm", 1e-3);
203203
assert(bn3);
204204
return bn3;
205205
}

0 commit comments

Comments
 (0)