Skip to content

Commit bc0d680

Browse files
authored
Merge pull request BVLC#5184 from shaibagon/fix_batch_norm_param_upgrade
fix harsh upgrade_proto for `"BatchNorm"` layer to zero instead of clear params
2 parents c86433a + a19357a commit bc0d680

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/caffe/util/upgrade_proto.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,13 @@ void UpgradeNetBatchNorm(NetParameter* net_param) {
10181018
// the previous BatchNorm layer definition.
10191019
if (net_param->layer(i).type() == "BatchNorm"
10201020
&& net_param->layer(i).param_size() == 3) {
1021-
net_param->mutable_layer(i)->clear_param();
1021+
// set lr_mult and decay_mult to zero. leave all other param intact.
1022+
for (int ip = 0; ip < net_param->layer(i).param_size(); ip++) {
1023+
ParamSpec* fixed_param_spec =
1024+
net_param->mutable_layer(i)->mutable_param(ip);
1025+
fixed_param_spec->set_lr_mult(0.f);
1026+
fixed_param_spec->set_decay_mult(0.f);
1027+
}
10221028
}
10231029
}
10241030
}

0 commit comments

Comments
 (0)