add V0NetParameter and UpgradeV0Net
authorJeff Donahue <jeff.donahue@gmail.com>
Sat, 15 Mar 2014 09:15:44 +0000 (02:15 -0700)
committerJeff Donahue <jeff.donahue@gmail.com>
Fri, 28 Mar 2014 06:42:28 +0000 (23:42 -0700)
include/caffe/util/upgrade_proto.hpp
src/caffe/proto/deprecated/caffe_v0_to_v1_bridge.proto
src/caffe/util/upgrade_proto.cpp

index fc7ac87..8b93829 100644 (file)
@@ -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);
 
index fd66c2d..782899c 100644 (file)
@@ -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
index 8b9b17f..4bd54dd 100644 (file)
@@ -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;