void UpgradeNetAsNeeded(const string& param_file, NetParameter* param) { if (NetNeedsUpgrade(*param)) { // NetParameter was specified using the old style (V0LayerParameter); try to // upgrade it. LOG(ERROR) << "Attempting to upgrade input file specified using deprecated " << "V0LayerParameter: " << param_file; NetParameter original_param(*param); if (!UpgradeV0Net(original_param, param)) { LOG(ERROR) << "Warning: had one or more problems upgrading " << "V0NetParameter to NetParameter (see above); continuing anyway."; } else { LOG(INFO) << "Successfully upgraded file specified using deprecated " << "V0LayerParameter"; } LOG(ERROR) << "Note that future Caffe releases will not support " << "V0NetParameter; use ./build/tools/upgrade_net_proto_text for " << "prototxt and ./build/tools/upgrade_net_proto_binary for model " << "weights upgrade this and any other net protos to the new format."; } // NetParameter uses old style data transformation fields; try to upgrade it. if (NetNeedsDataUpgrade(*param)) { LOG(ERROR) << "Attempting to upgrade input file specified using deprecated " << "transformation parameters: " << param_file; UpgradeNetDataTransformation(param); LOG(INFO) << "Successfully upgraded file specified using deprecated " << "data transformation parameters."; LOG(ERROR) << "Note that future Caffe releases will only support " << "transform_param messages for transformation fields."; } }
bool UpgradeNetAsNeeded(const string& param_file, NetParameter* param) { bool success = true; if (NetNeedsV0ToV1Upgrade(*param)) { // NetParameter was specified using the old style (V0LayerParameter); try to // upgrade it. LOG(INFO) << "Attempting to upgrade input file specified using deprecated " << "V0LayerParameter: " << param_file; NetParameter original_param(*param); if (!UpgradeV0Net(original_param, param)) { success = false; LOG(ERROR) << "Warning: had one or more problems upgrading " << "V0NetParameter to NetParameter (see above); continuing anyway."; } else { LOG(INFO) << "Successfully upgraded file specified using deprecated " << "V0LayerParameter"; } LOG(WARNING) << "Note that future Caffe releases will not support " << "V0NetParameter; use ./build/tools/upgrade_net_proto_text for " << "prototxt and ./build/tools/upgrade_net_proto_binary for model " << "weights upgrade this and any other net protos to the new format."; } // NetParameter uses old style data transformation fields; try to upgrade it. if (NetNeedsDataUpgrade(*param)) { LOG(INFO) << "Attempting to upgrade input file specified using deprecated " << "transformation parameters: " << param_file; UpgradeNetDataTransformation(param); LOG(INFO) << "Successfully upgraded file specified using deprecated " << "data transformation parameters."; LOG(WARNING) << "Note that future Caffe releases will only support " << "transform_param messages for transformation fields."; } if (NetNeedsV1ToV2Upgrade(*param)) { LOG(INFO) << "Attempting to upgrade input file specified using deprecated " << "V1LayerParameter: " << param_file; NetParameter original_param(*param); if (!UpgradeV1Net(original_param, param)) { success = false; LOG(ERROR) << "Warning: had one or more problems upgrading " << "V1LayerParameter (see above); continuing anyway."; } else { LOG(INFO) << "Successfully upgraded file specified using deprecated " << "V1LayerParameter"; } } // NetParameter uses old style input fields; try to upgrade it. /* if (NetNeedsInputUpgrade(*param)) { LOG(INFO) << "Attempting to upgrade input file specified using deprecated " << "input fields: " << param_file; UpgradeNetInput(param); LOG(INFO) << "Successfully upgraded file specified using deprecated " << "input fields."; LOG(WARNING) << "Note that future Caffe releases will only support " << "input layers and not input fields."; } */ // NetParameter uses old style batch norm layers; try to upgrade it. if (NetNeedsBatchNormUpgrade(*param)) { LOG(INFO) << "Attempting to upgrade batch norm layers using deprecated " << "params: " << param_file; UpgradeNetBatchNorm(param); LOG(INFO) << "Successfully upgraded batch norm layers using deprecated " << "params."; } return success; }