1 // Copyright 2013 Yangqing Jia
3 package caffe;
5 message BlobProto {
6 optional int32 num = 1 [default = 0];
7 optional int32 channels = 2 [default = 0];
8 optional int32 height = 3 [default = 0];
9 optional int32 width = 4 [default = 0];
10 repeated float data = 5 [packed=true];
11 repeated float diff = 6 [packed=true];
12 }
14 // The BlobProtoVector is simply a way to pass multiple blobproto instances
15 // around.
16 message BlobProtoVector {
17 repeated BlobProto blobs = 1;
18 }
20 message Datum {
21 optional int32 channels = 1;
22 optional int32 height = 2;
23 optional int32 width = 3;
24 // the actual image data, in bytes
25 optional bytes data = 4;
26 optional int32 label = 5;
27 // Optionally, the datum could also hold float data.
28 repeated float float_data = 6;
29 }
31 message FillerParameter {
32 // The filler type.
33 optional string type = 1 [default = 'constant'];
34 optional float value = 2 [default = 0]; // the value in constant filler
35 optional float min = 3 [default = 0]; // the min value in uniform filler
36 optional float max = 4 [default = 1]; // the max value in uniform filler
37 optional float mean = 5 [default = 0]; // the mean value in gaussian filler
38 optional float std = 6 [default = 1]; // the std value in gaussian filler
39 }
41 message LayerParameter {
42 optional string name = 1; // the layer name
43 optional string type = 2; // the string to specify the layer type
45 // Parameters to specify layers with inner products.
46 optional uint32 num_output = 3; // The number of outputs for the layer
47 optional bool biasterm = 4 [default = true]; // whether to have bias terms
48 optional FillerParameter weight_filler = 5; // The filler for the weight
49 optional FillerParameter bias_filler = 6; // The filler for the bias
51 optional uint32 pad = 7 [default = 0]; // The padding size
52 optional uint32 kernelsize = 8; // The kernel size
53 optional uint32 group = 9 [default = 1]; // The group size for group conv
54 optional uint32 stride = 10 [default = 1]; // The stride
55 enum PoolMethod {
56 MAX = 0;
57 AVE = 1;
58 STOCHASTIC = 2;
59 }
60 optional PoolMethod pool = 11 [default = MAX]; // The pooling method
61 optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio
63 optional uint32 local_size = 13 [default = 5]; // for local response norm
64 optional float alpha = 14 [default = 1.]; // for local response norm
65 optional float beta = 15 [default = 0.75]; // for local response norm
67 // For data layers, specify the data source
68 optional string source = 16;
69 // For data pre-processing, we can do simple scaling and subtracting the
70 // data mean, if provided. Note that the mean subtraction is always carried
71 // out before scaling.
72 optional float scale = 17 [ default = 1 ];
73 optional string meanfile = 18;
74 // For data layers, specify the batch size.
75 optional uint32 batchsize = 19;
76 // For data layers, specify if we would like to randomly crop an image.
77 optional uint32 cropsize = 20 [default = 0];
78 // For data layers, specify if we want to randomly mirror data.
79 optional bool mirror = 21 [default = false];
81 // The blobs containing the numeric parameters of the layer
82 repeated BlobProto blobs = 50;
83 // The ratio that is multiplied on the global learning rate. If you want to set
84 // the learning ratio for one blob, you need to set it for all blobs.
85 repeated float blobs_lr = 51;
86 // The weight decay that is multiplied on the global weight decay.
87 repeated float weight_decay = 52;
89 // The rand_skip variable is for the data layer to skip a few data points
90 // to avoid all asynchronous sgd clients to start at the same point. The skip
91 // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
92 // be larger than the number of keys in the leveldb.
93 optional uint32 rand_skip = 53 [ default = 0 ];
94 }
96 message LayerConnection {
97 optional LayerParameter layer = 1; // the layer parameter
98 repeated string bottom = 2; // the name of the bottom blobs
99 repeated string top = 3; // the name of the top blobs
100 }
102 message NetParameter {
103 optional string name = 1; // consider giving the network a name
104 repeated LayerConnection layers = 2; // a bunch of layers.
105 // The input blobs to the network.
106 repeated string input = 3;
107 // The dim of the input blobs. For each input blob there should be four
108 // values specifying the num, channels, height and width of the input blob.
109 // Thus, there should be a total of (4 * #input) numbers.
110 repeated int32 input_dim = 4;
111 // Whether the network will force every layer to carry out backward operation.
112 // If set False, then whether to carry out backward is determined
113 // automatically according to the net structure and learning rates.
114 optional bool force_backward = 5 [ default = false ];
115 }
117 message SolverParameter {
118 optional string train_net = 1; // The proto file for the training net.
119 optional string test_net = 2; // The proto file for the testing net.
120 // The number of iterations for each testing phase.
121 optional int32 test_iter = 3 [ default = 0 ];
122 // The number of iterations between two testing phases.
123 optional int32 test_interval = 4 [ default = 0 ];
124 optional float base_lr = 5; // The base learning rate
125 // the number of iterations between displaying info. If display = 0, no info
126 // will be displayed.
127 optional int32 display = 6;
128 optional int32 max_iter = 7; // the maximum number of iterations
129 optional string lr_policy = 8; // The learning rate decay policy.
130 optional float gamma = 9; // The parameter to compute the learning rate.
131 optional float power = 10; // The parameter to compute the learning rate.
132 optional float momentum = 11; // The momentum value.
133 optional float weight_decay = 12; // The weight decay.
134 optional int32 stepsize = 13; // the stepsize for learning rate policy "step"
135 optional int32 snapshot = 14 [default = 0]; // The snapshot interval
136 optional string snapshot_prefix = 15; // The prefix for the snapshot.
137 // whether to snapshot diff in the results or not. Snapshotting diff will help
138 // debugging but the final protocol buffer size will be much larger.
139 optional bool snapshot_diff = 16 [ default = false];
141 // the asynchronous solver stuff
142 optional string tcp_port = 20 [ default = "20901"];
143 optional string tcp_server = 21;
144 optional int32 communication_interval = 22;
145 }
147 // A message that stores the solver snapshots
148 message SolverState {
149 optional int32 iter = 1; // The current iteration
150 optional string learned_net = 2; // The file that stores the learned net.
151 repeated BlobProto history = 3; // The history for sgd solvers
152 }