From 69ddcc84a6c014bb1bb3d1d50ac52c75f26fc5ac Mon Sep 17 00:00:00 2001 From: Jeff Donahue Date: Sat, 15 Mar 2014 02:15:44 -0700 Subject: [PATCH] add V0NetParameter and UpgradeV0Net --- include/caffe/util/upgrade_proto.hpp | 2 ++ src/caffe/proto/deprecated/caffe_v0_to_v1_bridge.proto | 15 +++++++++++++++ src/caffe/util/upgrade_proto.cpp | 13 +++++++++++++ 3 files changed, 30 insertions(+) diff --git a/include/caffe/util/upgrade_proto.hpp b/include/caffe/util/upgrade_proto.hpp index fc7ac87..8b93829 100644 --- a/include/caffe/util/upgrade_proto.hpp +++ b/include/caffe/util/upgrade_proto.hpp @@ -17,6 +17,8 @@ using std::string; namespace caffe { +bool UpgradeV0Net(const V0NetParameter& v0_net_param, NetParameter* net_param); + bool UpgradeV0LayerConnection(const V0LayerConnection& v0_layer_connection, LayerParameter* layer_param); diff --git a/src/caffe/proto/deprecated/caffe_v0_to_v1_bridge.proto b/src/caffe/proto/deprecated/caffe_v0_to_v1_bridge.proto index fd66c2d..782899c 100644 --- a/src/caffe/proto/deprecated/caffe_v0_to_v1_bridge.proto +++ b/src/caffe/proto/deprecated/caffe_v0_to_v1_bridge.proto @@ -4,6 +4,21 @@ import "caffe/proto/caffe.proto"; package caffe; +message V0NetParameter { + optional string name = 1; // consider giving the network a name + repeated V0LayerConnection layers = 2; // a bunch of layers. + // The input blobs to the network. + repeated string input = 3; + // The dim of the input blobs. For each input blob there should be four + // values specifying the num, channels, height and width of the input blob. + // Thus, there should be a total of (4 * #input) numbers. + repeated int32 input_dim = 4; + // Whether the network will force every layer to carry out backward operation. + // If set False, then whether to carry out backward is determined + // automatically according to the net structure and learning rates. + optional bool force_backward = 5 [default = false]; +} + message V0LayerParameter { optional string name = 1; // the layer name optional string type = 2; // the string to specify the layer type diff --git a/src/caffe/util/upgrade_proto.cpp b/src/caffe/util/upgrade_proto.cpp index 8b9b17f..4bd54dd 100644 --- a/src/caffe/util/upgrade_proto.cpp +++ b/src/caffe/util/upgrade_proto.cpp @@ -22,6 +22,19 @@ using std::string; namespace caffe { +bool UpgradeV0Net(const V0NetParameter& v0_net_param, + NetParameter* net_param) { + bool full_compatibility = true; + net_param->Clear(); + if (v0_net_param.has_name()) { + net_param->set_name(v0_net_param.name()); + } + for (int i = 0; i < v0_net_param.layers_size(); ++i) { + full_compatibility &= UpgradeV0LayerConnection(v0_net_param.layers(i), + net_param->add_layers()); + } +} + bool UpgradeV0LayerConnection(const V0LayerConnection& v0_layer_connection, LayerParameter* layer_param) { bool full_compatibility = true; -- 2.7.4