this->RunV0UpgradeTest(input_proto, expected_output_proto);
}
+// Test any layer or parameter upgrades not covered by other tests.
TYPED_TEST(V0UpgradeTest, TestAllParams) {
const string& input_proto =
"name: 'CaffeNet' "
"} "
"layers { "
" layer { "
+ " name: 'window_data' "
+ " type: 'window_data' "
+ " source: '/home/jiayq/Data/ILSVRC12/train-leveldb' "
+ " meanfile: '/home/jiayq/Data/ILSVRC12/image_mean.binaryproto' "
+ " batchsize: 256 "
+ " cropsize: 227 "
+ " mirror: true "
+ " det_fg_threshold: 0.25 "
+ " det_bg_threshold: 0.75 "
+ " det_fg_fraction: 0.5 "
+ " det_context_pad: 16 "
+ " det_crop_mode: 'square' "
+ " } "
+ " top: 'window_data' "
+ " top: 'window_label' "
+ "} "
+ "layers { "
+ " layer { "
" name: 'hdf5data' "
" type: 'hdf5_data' "
" source: '/my/hdf5/data' "
"} "
"layers { "
" layer { "
+ " name: 'euclidean_loss' "
+ " type: 'euclidean_loss' "
+ " } "
+ "} "
+ "layers { "
+ " layer { "
" name: 'flatten' "
" type: 'flatten' "
" } "
"} "
"layers { "
" layer { "
+ " name: 'images' "
+ " type: 'images' "
+ " } "
+ "} "
+ "layers { "
+ " layer { "
" name: 'multinomial_logistic_loss' "
" type: 'multinomial_logistic_loss' "
" } "
" top: 'label' "
"} "
"layers { "
+ " name: 'window_data' "
+ " type: WINDOW_DATA "
+ " window_data_param { "
+ " source: '/home/jiayq/Data/ILSVRC12/train-leveldb' "
+ " mean_file: '/home/jiayq/Data/ILSVRC12/image_mean.binaryproto' "
+ " batch_size: 256 "
+ " crop_size: 227 "
+ " mirror: true "
+ " fg_threshold: 0.25 "
+ " bg_threshold: 0.75 "
+ " fg_fraction: 0.5 "
+ " context_pad: 16 "
+ " crop_mode: 'square' "
+ " } "
+ " top: 'window_data' "
+ " top: 'window_label' "
+ "} "
+ "layers { "
" name: 'hdf5data' "
" type: HDF5_DATA "
" hdf5_data_param { "
" type: BNLL "
"} "
"layers { "
+ " name: 'euclidean_loss' "
+ " type: EUCLIDEAN_LOSS "
+ "} "
+ "layers { "
" name: 'flatten' "
" type: FLATTEN "
"} "
" type: IM2COL "
"} "
"layers { "
+ " name: 'images' "
+ " type: IMAGE_DATA "
+ "} "
+ "layers { "
" name: 'multinomial_logistic_loss' "
" type: MULTINOMIAL_LOGISTIC_LOSS "
"} "
} else if (type == "hdf5_data") {
layer_param->mutable_hdf5_data_param()->set_source(
v0_layer_param.source());
+ } else if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_source(
+ v0_layer_param.source());
} else if (type == "infogain_loss") {
layer_param->mutable_infogain_loss_param()->set_source(
v0_layer_param.source());
if (type == "data") {
layer_param->mutable_data_param()->set_mean_file(
v0_layer_param.meanfile());
+ } else if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_mean_file(
+ v0_layer_param.meanfile());
} else {
LOG(ERROR) << "Unknown parameter meanfile for layer type " << type;
is_fully_compatible = false;
} else if (type == "hdf5_data") {
layer_param->mutable_hdf5_data_param()->set_batch_size(
v0_layer_param.batchsize());
+ } else if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_batch_size(
+ v0_layer_param.batchsize());
} else {
LOG(ERROR) << "Unknown parameter batchsize for layer type " << type;
is_fully_compatible = false;
if (type == "data") {
layer_param->mutable_data_param()->set_crop_size(
v0_layer_param.cropsize());
+ } else if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_crop_size(
+ v0_layer_param.cropsize());
} else {
LOG(ERROR) << "Unknown parameter cropsize for layer type " << type;
is_fully_compatible = false;
if (v0_layer_param.has_mirror()) {
if (type == "data") {
layer_param->mutable_data_param()->set_mirror(v0_layer_param.mirror());
+ } else if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_mirror(
+ v0_layer_param.mirror());
} else {
LOG(ERROR) << "Unknown parameter mirror for layer type " << type;
is_fully_compatible = false;
is_fully_compatible = false;
}
}
+ if (v0_layer_param.has_det_fg_threshold()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_fg_threshold(
+ v0_layer_param.det_fg_threshold());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_fg_threshold for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_det_bg_threshold()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_bg_threshold(
+ v0_layer_param.det_bg_threshold());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_bg_threshold for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_det_fg_fraction()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_fg_fraction(
+ v0_layer_param.det_fg_fraction());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_fg_fraction for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_det_context_pad()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_context_pad(
+ v0_layer_param.det_context_pad());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_context_pad for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_det_crop_mode()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_crop_mode(
+ v0_layer_param.det_crop_mode());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_crop_mode for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
}
return is_fully_compatible;
}
return LayerParameter_LayerType_HDF5_DATA;
} else if (type == "im2col") {
return LayerParameter_LayerType_IM2COL;
+ } else if (type == "images") {
+ return LayerParameter_LayerType_IMAGE_DATA;
} else if (type == "infogain_loss") {
return LayerParameter_LayerType_INFOGAIN_LOSS;
} else if (type == "innerproduct") {
return LayerParameter_LayerType_SPLIT;
} else if (type == "tanh") {
return LayerParameter_LayerType_TANH;
+ } else if (type == "window_data") {
+ return LayerParameter_LayerType_WINDOW_DATA;
} else {
LOG(FATAL) << "Unknown layer name: " << type;
- return LayerParameter_LayerType(-1);
+ return LayerParameter_LayerType_NONE;
}
}