Skip to content

Commit

Permalink
refuse to upgrade net with layer/layers inconsistency
Browse files Browse the repository at this point in the history
die loudly if a net definition (prototxt) mixes proto formats by
defining both `layer` and `layers` fields instead of complaining but
discarding and continuing.

fix BVLC#3381
  • Loading branch information
shelhamer committed Mar 1, 2016
1 parent ff6c6e4 commit 7eaeb3a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/caffe/util/upgrade_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,14 @@ void UpgradeNetDataTransformation(NetParameter* net_param) {
}

bool UpgradeV1Net(const NetParameter& v1_net_param, NetParameter* net_param) {
bool is_fully_compatible = true;
if (v1_net_param.layer_size() > 0) {
LOG(ERROR) << "Input NetParameter to be upgraded already specifies 'layer' "
<< "fields; these will be ignored for the upgrade.";
is_fully_compatible = false;
LOG(FATAL) << "Refusing to upgrade inconsistent NetParameter input; "
<< "the definition includes both 'layer' and 'layers' fields. "
<< "The current format defines 'layer' fields with string type like "
<< "layer { type: 'Layer' ... } and not layers { type: LAYER ... }. "
<< "Manually switch the definition to 'layer' format to continue.";
}
bool is_fully_compatible = true;
net_param->CopyFrom(v1_net_param);
net_param->clear_layers();
net_param->clear_layer();
Expand Down

0 comments on commit 7eaeb3a

Please sign in to comment.