841f24f79812b5072889c2e6f427597819aa3dca
[platform/upstream/opencv.git] / modules / dnn / src / caffe / opencv-caffe.proto
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //COPYRIGHT
3 //
4 //All contributions by the University of California:
5 //Copyright (c) 2014, The Regents of the University of California (Regents)
6 //All rights reserved.
7 //
8 //All other contributions:
9 //Copyright (c) 2014, the respective contributors
10 //All rights reserved.
11 //
12 //Caffe uses a shared copyright model: each contributor holds copyright over
13 //their contributions to Caffe. The project versioning records all such
14 //contribution and copyright details. If a contributor wants to further mark
15 //their specific copyright on a particular contribution, they should indicate
16 //their copyright solely in the commit message of the change when it is
17 //committed.
18 //
19 //LICENSE
20 //
21 //Redistribution and use in source and binary forms, with or without
22 //modification, are permitted provided that the following conditions are met:
23 //
24 //1. Redistributions of source code must retain the above copyright notice, this
25 //   list of conditions and the following disclaimer.
26 //2. Redistributions in binary form must reproduce the above copyright notice,
27 //   this list of conditions and the following disclaimer in the documentation
28 //   and/or other materials provided with the distribution.
29 //
30 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 //DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
34 //ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 //
41 //CONTRIBUTION AGREEMENT
42 //
43 //By contributing to the BVLC/caffe repository through pull-request, comment,
44 //or otherwise, the contributor releases their content to the
45 //license and copyright terms herein.
46 //
47 //M*/
48
49 syntax = "proto2";
50
51 package opencv_caffe;
52
53 // NVidia's Caffe feature is used to store fp16 weights, https://github.com/NVIDIA/caffe:
54 // Math and storage types
55 enum Type {
56   DOUBLE = 0;
57   FLOAT = 1;
58   FLOAT16 = 2;
59   INT = 3;  // math not supported
60   UINT = 4;  // math not supported
61 }
62
63 // Specifies the shape (dimensions) of a Blob.
64 message BlobShape {
65   repeated int64 dim = 1 [packed = true];
66 }
67
68 message BlobProto {
69   optional BlobShape shape = 7;
70   repeated float data = 5 [packed = true];
71   repeated float diff = 6 [packed = true];
72   repeated double double_data = 8 [packed = true];
73   repeated double double_diff = 9 [packed = true];
74
75   // NVidia's Caffe fields begin.
76   optional Type raw_data_type = 10;
77   optional bytes raw_data = 12 [packed = false];
78   // NVidia's Caffe fields end.
79
80   // 4D dimensions -- deprecated.  Use "shape" instead.
81   optional int32 num = 1 [default = 0];
82   optional int32 channels = 2 [default = 0];
83   optional int32 height = 3 [default = 0];
84   optional int32 width = 4 [default = 0];
85 }
86
87 // The BlobProtoVector is simply a way to pass multiple blobproto instances
88 // around.
89 message BlobProtoVector {
90   repeated BlobProto blobs = 1;
91 }
92
93 message PermuteParameter {
94   // The new orders of the axes of data. Notice it should be with
95   // in the same range as the input data, and it starts from 0.
96   // Do not provide repeated order.
97   repeated uint32 order = 1;
98 }
99
100 // Message that stores parameters used by NormalizeBBoxLayer
101 message NormalizeBBoxParameter {
102   optional bool across_spatial = 1 [default = true];
103   // Initial value of scale. Default is 1.0 for all
104   optional FillerParameter scale_filler = 2;
105   // Whether or not scale parameters are shared across channels.
106   optional bool channel_shared = 3 [default = true];
107   // Epsilon for not dividing by zero while normalizing variance
108   optional float eps = 4 [default = 1e-10];
109 }
110
111 // Message that store parameters used by PriorBoxLayer
112 message PriorBoxParameter {
113   // Encode/decode type.
114   enum CodeType {
115     CORNER = 1;
116     CENTER_SIZE = 2;
117   }
118   // Minimum box size (in pixels). Required!
119   optional float min_size = 1;
120   // Maximum box size (in pixels). Required!
121   optional float max_size = 2;
122   // Various of aspect ratios. Duplicate ratios will be ignored.
123   // If none is provided, we use default ratio 1.
124   repeated float aspect_ratio = 3;
125   // If true, will flip each aspect ratio.
126   // For example, if there is aspect ratio "r",
127   // we will generate aspect ratio "1.0/r" as well.
128   optional bool flip = 4 [default = true];
129   // If true, will clip the prior so that it is within [0, 1]
130   optional bool clip = 5 [default = true];
131   // Variance for adjusting the prior bboxes.
132   repeated float variance = 6;
133   // By default, we calculate img_height, img_width, step_x, step_y based on
134   // bottom[0] (feat) and bottom[1] (img). Unless these values are explicitely
135   // provided.
136   // Explicitly provide the img_size.
137   optional uint32 img_size = 7;
138   // Either img_size or img_h/img_w should be specified; not both.
139   optional uint32 img_h = 8;
140   optional uint32 img_w = 9;
141   // Explicitly provide the step size.
142   optional float step = 10;
143   // Either step or step_h/step_w should be specified; not both.
144   optional float step_h = 11;
145   optional float step_w = 12;
146   // Offset to the top left corner of each cell.
147   optional float offset = 13 [default = 0.5];
148   // Offset to the top corner of each cell.
149   repeated float offset_h = 14;
150   // Offset to the left corner of each cell.
151   repeated float offset_w = 15;
152   // Priox boxes width (in pixels).
153   repeated float width = 16;
154   // Priox boxes height (in pixels).
155   repeated float height = 17;
156 }
157
158 // Message that store parameters used by DetectionOutputLayer
159 message DetectionOutputParameter {
160   // Number of classes to be predicted. Required!
161   optional uint32 num_classes = 1;
162   // If true, bounding box are shared among different classes.
163   optional bool share_location = 2 [default = true];
164   // Background label id. If there is no background class,
165   // set it as -1.
166   optional int32 background_label_id = 3 [default = 0];
167   // Parameters used for non maximum suppression.
168   optional NonMaximumSuppressionParameter nms_param = 4;
169   // Parameters used for saving detection results.
170   optional SaveOutputParameter save_output_param = 5;
171   // Type of coding method for bbox.
172   optional PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
173   // If true, variance is encoded in target; otherwise we need to adjust the
174   // predicted offset accordingly.
175   optional bool variance_encoded_in_target = 8 [default = false];
176   // Number of total bboxes to be kept per image after nms step.
177   // -1 means keeping all bboxes after nms step.
178   optional int32 keep_top_k = 7 [default = -1];
179   // Only consider detections whose confidences are larger than a threshold.
180   // If not provided, consider all boxes.
181   optional float confidence_threshold = 9;
182 }
183
184 message Datum {
185   optional int32 channels = 1;
186   optional int32 height = 2;
187   optional int32 width = 3;
188   // the actual image data, in bytes
189   optional bytes data = 4;
190   optional int32 label = 5;
191   // Optionally, the datum could also hold float data.
192   repeated float float_data = 6;
193   // If true data contains an encoded image that need to be decoded
194   optional bool encoded = 7 [default = false];
195 }
196
197 message FillerParameter {
198   // The filler type.
199   optional string type = 1 [default = 'constant'];
200   optional float value = 2 [default = 0]; // the value in constant filler
201   optional float min = 3 [default = 0]; // the min value in uniform filler
202   optional float max = 4 [default = 1]; // the max value in uniform filler
203   optional float mean = 5 [default = 0]; // the mean value in Gaussian filler
204   optional float std = 6 [default = 1]; // the std value in Gaussian filler
205   // The expected number of non-zero output weights for a given input in
206   // Gaussian filler -- the default -1 means don't perform sparsification.
207   optional int32 sparse = 7 [default = -1];
208   // Normalize the filler variance by fan_in, fan_out, or their average.
209   // Applies to 'xavier' and 'msra' fillers.
210   enum VarianceNorm {
211     FAN_IN = 0;
212     FAN_OUT = 1;
213     AVERAGE = 2;
214   }
215   optional VarianceNorm variance_norm = 8 [default = FAN_IN];
216 }
217
218 message NetParameter {
219   optional string name = 1; // consider giving the network a name
220   // DEPRECATED. See InputParameter. The input blobs to the network.
221   repeated string input = 3;
222   // DEPRECATED. See InputParameter. The shape of the input blobs.
223   repeated BlobShape input_shape = 8;
224
225   // 4D input dimensions -- deprecated.  Use "input_shape" instead.
226   // If specified, for each input blob there should be four
227   // values specifying the num, channels, height and width of the input blob.
228   // Thus, there should be a total of (4 * #input) numbers.
229   repeated int32 input_dim = 4;
230
231   // Whether the network will force every layer to carry out backward operation.
232   // If set False, then whether to carry out backward is determined
233   // automatically according to the net structure and learning rates.
234   optional bool force_backward = 5 [default = false];
235   // The current "state" of the network, including the phase, level, and stage.
236   // Some layers may be included/excluded depending on this state and the states
237   // specified in the layers' include and exclude fields.
238   optional NetState state = 6;
239
240   // Print debugging information about results while running Net::Forward,
241   // Net::Backward, and Net::Update.
242   optional bool debug_info = 7 [default = false];
243
244   // The layers that make up the net.  Each of their configurations, including
245   // connectivity and behavior, is specified as a LayerParameter.
246   repeated LayerParameter layer = 100;  // ID 100 so layers are printed last.
247
248   // DEPRECATED: use 'layer' instead.
249   repeated V1LayerParameter layers = 2;
250 }
251
252 // NOTE
253 // Update the next available ID when you add a new SolverParameter field.
254 //
255 // SolverParameter next available ID: 41 (last added: type)
256 message SolverParameter {
257   //////////////////////////////////////////////////////////////////////////////
258   // Specifying the train and test networks
259   //
260   // Exactly one train net must be specified using one of the following fields:
261   //     train_net_param, train_net, net_param, net
262   // One or more test nets may be specified using any of the following fields:
263   //     test_net_param, test_net, net_param, net
264   // If more than one test net field is specified (e.g., both net and
265   // test_net are specified), they will be evaluated in the field order given
266   // above: (1) test_net_param, (2) test_net, (3) net_param/net.
267   // A test_iter must be specified for each test_net.
268   // A test_level and/or a test_stage may also be specified for each test_net.
269   //////////////////////////////////////////////////////////////////////////////
270
271   // Proto filename for the train net, possibly combined with one or more
272   // test nets.
273   optional string net = 24;
274   // Inline train net param, possibly combined with one or more test nets.
275   optional NetParameter net_param = 25;
276
277   optional string train_net = 1; // Proto filename for the train net.
278   repeated string test_net = 2; // Proto filenames for the test nets.
279   optional NetParameter train_net_param = 21; // Inline train net params.
280   repeated NetParameter test_net_param = 22; // Inline test net params.
281
282   // The states for the train/test nets. Must be unspecified or
283   // specified once per net.
284   //
285   // By default, all states will have solver = true;
286   // train_state will have phase = TRAIN,
287   // and all test_state's will have phase = TEST.
288   // Other defaults are set according to the NetState defaults.
289   optional NetState train_state = 26;
290   repeated NetState test_state = 27;
291
292   // The number of iterations for each test net.
293   repeated int32 test_iter = 3;
294
295   // The number of iterations between two testing phases.
296   optional int32 test_interval = 4 [default = 0];
297   optional bool test_compute_loss = 19 [default = false];
298   // If true, run an initial test pass before the first iteration,
299   // ensuring memory availability and printing the starting value of the loss.
300   optional bool test_initialization = 32 [default = true];
301   optional float base_lr = 5; // The base learning rate
302   // the number of iterations between displaying info. If display = 0, no info
303   // will be displayed.
304   optional int32 display = 6;
305   // Display the loss averaged over the last average_loss iterations
306   optional int32 average_loss = 33 [default = 1];
307   optional int32 max_iter = 7; // the maximum number of iterations
308   // accumulate gradients over `iter_size` x `batch_size` instances
309   optional int32 iter_size = 36 [default = 1];
310
311   // The learning rate decay policy. The currently implemented learning rate
312   // policies are as follows:
313   //    - fixed: always return base_lr.
314   //    - step: return base_lr * gamma ^ (floor(iter / step))
315   //    - exp: return base_lr * gamma ^ iter
316   //    - inv: return base_lr * (1 + gamma * iter) ^ (- power)
317   //    - multistep: similar to step but it allows non uniform steps defined by
318   //      stepvalue
319   //    - poly: the effective learning rate follows a polynomial decay, to be
320   //      zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power)
321   //    - sigmoid: the effective learning rate follows a sigmod decay
322   //      return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize))))
323   //
324   // where base_lr, max_iter, gamma, step, stepvalue and power are defined
325   // in the solver parameter protocol buffer, and iter is the current iteration.
326   optional string lr_policy = 8;
327   optional float gamma = 9; // The parameter to compute the learning rate.
328   optional float power = 10; // The parameter to compute the learning rate.
329   optional float momentum = 11; // The momentum value.
330   optional float weight_decay = 12; // The weight decay.
331   // regularization types supported: L1 and L2
332   // controlled by weight_decay
333   optional string regularization_type = 29 [default = "L2"];
334   // the stepsize for learning rate policy "step"
335   optional int32 stepsize = 13;
336   // the stepsize for learning rate policy "multistep"
337   repeated int32 stepvalue = 34;
338
339   // Set clip_gradients to >= 0 to clip parameter gradients to that L2 norm,
340   // whenever their actual L2 norm is larger.
341   optional float clip_gradients = 35 [default = -1];
342
343   optional int32 snapshot = 14 [default = 0]; // The snapshot interval
344   optional string snapshot_prefix = 15; // The prefix for the snapshot.
345   // whether to snapshot diff in the results or not. Snapshotting diff will help
346   // debugging but the final protocol buffer size will be much larger.
347   optional bool snapshot_diff = 16 [default = false];
348   enum SnapshotFormat {
349     HDF5 = 0;
350     BINARYPROTO = 1;
351   }
352   optional SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
353   // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default.
354   enum SolverMode {
355     CPU = 0;
356     GPU = 1;
357   }
358   optional SolverMode solver_mode = 17 [default = GPU];
359   // the device_id will that be used in GPU mode. Use device_id = 0 in default.
360   optional int32 device_id = 18 [default = 0];
361   // If non-negative, the seed with which the Solver will initialize the Caffe
362   // random number generator -- useful for reproducible results. Otherwise,
363   // (and by default) initialize using a seed derived from the system clock.
364   optional int64 random_seed = 20 [default = -1];
365
366   // type of the solver
367   optional string type = 40 [default = "SGD"];
368
369   // numerical stability for RMSProp, AdaGrad and AdaDelta and Adam
370   optional float delta = 31 [default = 1e-8];
371   // parameters for the Adam solver
372   optional float momentum2 = 39 [default = 0.999];
373
374   // RMSProp decay value
375   // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t)
376   optional float rms_decay = 38 [default = 0.99];
377
378   // If true, print information about the state of the net that may help with
379   // debugging learning problems.
380   optional bool debug_info = 23 [default = false];
381
382   // If false, don't save a snapshot after training finishes.
383   optional bool snapshot_after_train = 28 [default = true];
384
385   // DEPRECATED: old solver enum types, use string instead
386   enum SolverType {
387     SGD = 0;
388     NESTEROV = 1;
389     ADAGRAD = 2;
390     RMSPROP = 3;
391     ADADELTA = 4;
392     ADAM = 5;
393   }
394   // DEPRECATED: use type instead of solver_type
395   optional SolverType solver_type = 30 [default = SGD];
396 }
397
398 // A message that stores the solver snapshots
399 message SolverState {
400   optional int32 iter = 1; // The current iteration
401   optional string learned_net = 2; // The file that stores the learned net.
402   repeated BlobProto history = 3; // The history for sgd solvers
403   optional int32 current_step = 4 [default = 0]; // The current step for learning rate
404 }
405
406 enum Phase {
407    TRAIN = 0;
408    TEST = 1;
409 }
410
411 message NetState {
412   optional Phase phase = 1 [default = TEST];
413   optional int32 level = 2 [default = 0];
414   repeated string stage = 3;
415 }
416
417 message NetStateRule {
418   // Set phase to require the NetState have a particular phase (TRAIN or TEST)
419   // to meet this rule.
420   optional Phase phase = 1;
421
422   // Set the minimum and/or maximum levels in which the layer should be used.
423   // Leave undefined to meet the rule regardless of level.
424   optional int32 min_level = 2;
425   optional int32 max_level = 3;
426
427   // Customizable sets of stages to include or exclude.
428   // The net must have ALL of the specified stages and NONE of the specified
429   // "not_stage"s to meet the rule.
430   // (Use multiple NetStateRules to specify conjunctions of stages.)
431   repeated string stage = 4;
432   repeated string not_stage = 5;
433 }
434
435 // Specifies training parameters (multipliers on global learning constants,
436 // and the name and other settings used for weight sharing).
437 message ParamSpec {
438   // The names of the parameter blobs -- useful for sharing parameters among
439   // layers, but never required otherwise.  To share a parameter between two
440   // layers, give it a (non-empty) name.
441   optional string name = 1;
442
443   // Whether to require shared weights to have the same shape, or just the same
444   // count -- defaults to STRICT if unspecified.
445   optional DimCheckMode share_mode = 2;
446   enum DimCheckMode {
447     // STRICT (default) requires that num, channels, height, width each match.
448     STRICT = 0;
449     // PERMISSIVE requires only the count (num*channels*height*width) to match.
450     PERMISSIVE = 1;
451   }
452
453   // The multiplier on the global learning rate for this parameter.
454   optional float lr_mult = 3 [default = 1.0];
455
456   // The multiplier on the global weight decay for this parameter.
457   optional float decay_mult = 4 [default = 1.0];
458 }
459
460 // NOTE
461 // Update the next available ID when you add a new LayerParameter field.
462 //
463 // LayerParameter next available layer-specific ID: 147 (last added: recurrent_param)
464 message LayerParameter {
465   optional string name = 1; // the layer name
466   optional string type = 2; // the layer type
467   repeated string bottom = 3; // the name of each bottom blob
468   repeated string top = 4; // the name of each top blob
469
470   // The train / test phase for computation.
471   optional Phase phase = 10;
472
473   // The amount of weight to assign each top blob in the objective.
474   // Each layer assigns a default value, usually of either 0 or 1,
475   // to each top blob.
476   repeated float loss_weight = 5;
477
478   // Specifies training parameters (multipliers on global learning constants,
479   // and the name and other settings used for weight sharing).
480   repeated ParamSpec param = 6;
481
482   // The blobs containing the numeric parameters of the layer.
483   repeated BlobProto blobs = 7;
484
485   // Specifies whether to backpropagate to each bottom. If unspecified,
486   // Caffe will automatically infer whether each input needs backpropagation
487   // to compute parameter gradients. If set to true for some inputs,
488   // backpropagation to those inputs is forced; if set false for some inputs,
489   // backpropagation to those inputs is skipped.
490   //
491   // The size must be either 0 or equal to the number of bottoms.
492   repeated bool propagate_down = 11;
493
494   // Rules controlling whether and when a layer is included in the network,
495   // based on the current NetState.  You may specify a non-zero number of rules
496   // to include OR exclude, but not both.  If no include or exclude rules are
497   // specified, the layer is always included.  If the current NetState meets
498   // ANY (i.e., one or more) of the specified rules, the layer is
499   // included/excluded.
500   repeated NetStateRule include = 8;
501   repeated NetStateRule exclude = 9;
502
503   // Parameters for data pre-processing.
504   optional TransformationParameter transform_param = 100;
505
506   // Parameters shared by loss layers.
507   optional LossParameter loss_param = 101;
508
509   // Layer type-specific parameters.
510   //
511   // Note: certain layers may have more than one computational engine
512   // for their implementation. These layers include an Engine type and
513   // engine parameter for selecting the implementation.
514   // The default for the engine is set by the ENGINE switch at compile-time.
515   optional AccuracyParameter accuracy_param = 102;
516   optional ArgMaxParameter argmax_param = 103;
517   optional BatchNormParameter batch_norm_param = 139;
518   optional BiasParameter bias_param = 141;
519   optional ConcatParameter concat_param = 104;
520   optional ContrastiveLossParameter contrastive_loss_param = 105;
521   optional ConvolutionParameter convolution_param = 106;
522   optional CropParameter crop_param = 144;
523   optional DataParameter data_param = 107;
524   optional DetectionOutputParameter detection_output_param = 147;
525   optional DropoutParameter dropout_param = 108;
526   optional DummyDataParameter dummy_data_param = 109;
527   optional EltwiseParameter eltwise_param = 110;
528   optional ELUParameter elu_param = 140;
529   optional EmbedParameter embed_param = 137;
530   optional ExpParameter exp_param = 111;
531   optional FlattenParameter flatten_param = 135;
532   optional HDF5DataParameter hdf5_data_param = 112;
533   optional HDF5OutputParameter hdf5_output_param = 113;
534   optional HingeLossParameter hinge_loss_param = 114;
535   optional ImageDataParameter image_data_param = 115;
536   optional InfogainLossParameter infogain_loss_param = 116;
537   optional InnerProductParameter inner_product_param = 117;
538   optional InputParameter input_param = 143;
539   optional LogParameter log_param = 134;
540   optional LRNParameter lrn_param = 118;
541   optional MemoryDataParameter memory_data_param = 119;
542   optional MVNParameter mvn_param = 120;
543   optional NormalizeBBoxParameter norm_param = 149;
544   optional PermuteParameter permute_param = 148;
545   optional ParameterParameter parameter_param = 145;
546   optional PoolingParameter pooling_param = 121;
547   optional PowerParameter power_param = 122;
548   optional PReLUParameter prelu_param = 131;
549   optional PriorBoxParameter prior_box_param = 150;
550   optional PythonParameter python_param = 130;
551   optional RecurrentParameter recurrent_param = 146;
552   optional ReductionParameter reduction_param = 136;
553   optional ReLUParameter relu_param = 123;
554   optional ReshapeParameter reshape_param = 133;
555   optional ROIPoolingParameter roi_pooling_param = 8266711;  // https://github.com/rbgirshick/caffe-fast-rcnn/tree/fast-rcnn
556   optional ScaleParameter scale_param = 142;
557   optional SigmoidParameter sigmoid_param = 124;
558   optional SoftmaxParameter softmax_param = 125;
559   optional SPPParameter spp_param = 132;
560   optional SliceParameter slice_param = 126;
561   optional TanHParameter tanh_param = 127;
562   optional ThresholdParameter threshold_param = 128;
563   optional TileParameter tile_param = 138;
564   optional WindowDataParameter window_data_param = 129;
565 }
566
567 // Message that stores parameters used to apply transformation
568 // to the data layer's data
569 message TransformationParameter {
570   // For data pre-processing, we can do simple scaling and subtracting the
571   // data mean, if provided. Note that the mean subtraction is always carried
572   // out before scaling.
573   optional float scale = 1 [default = 1];
574   // Specify if we want to randomly mirror data.
575   optional bool mirror = 2 [default = false];
576   // Specify if we would like to randomly crop an image.
577   optional uint32 crop_size = 3 [default = 0];
578   // mean_file and mean_value cannot be specified at the same time
579   optional string mean_file = 4;
580   // if specified can be repeated once (would subtract it from all the channels)
581   // or can be repeated the same number of times as channels
582   // (would subtract them from the corresponding channel)
583   repeated float mean_value = 5;
584   // Force the decoded image to have 3 color channels.
585   optional bool force_color = 6 [default = false];
586   // Force the decoded image to have 1 color channels.
587   optional bool force_gray = 7 [default = false];
588 }
589
590 // Message that stores parameters shared by loss layers
591 message LossParameter {
592   // If specified, ignore instances with the given label.
593   optional int32 ignore_label = 1;
594   // How to normalize the loss for loss layers that aggregate across batches,
595   // spatial dimensions, or other dimensions.  Currently only implemented in
596   // SoftmaxWithLoss and SigmoidCrossEntropyLoss layers.
597   enum NormalizationMode {
598     // Divide by the number of examples in the batch times spatial dimensions.
599     // Outputs that receive the ignore label will NOT be ignored in computing
600     // the normalization factor.
601     FULL = 0;
602     // Divide by the total number of output locations that do not take the
603     // ignore_label.  If ignore_label is not set, this behaves like FULL.
604     VALID = 1;
605     // Divide by the batch size.
606     BATCH_SIZE = 2;
607     // Do not normalize the loss.
608     NONE = 3;
609   }
610   // For historical reasons, the default normalization for
611   // SigmoidCrossEntropyLoss is BATCH_SIZE and *not* VALID.
612   optional NormalizationMode normalization = 3 [default = VALID];
613   // Deprecated.  Ignored if normalization is specified.  If normalization
614   // is not specified, then setting this to false will be equivalent to
615   // normalization = BATCH_SIZE to be consistent with previous behavior.
616   optional bool normalize = 2;
617 }
618
619 // Messages that store parameters used by individual layer types follow, in
620 // alphabetical order.
621
622 message AccuracyParameter {
623   // When computing accuracy, count as correct by comparing the true label to
624   // the top k scoring classes.  By default, only compare to the top scoring
625   // class (i.e. argmax).
626   optional uint32 top_k = 1 [default = 1];
627
628   // The "label" axis of the prediction blob, whose argmax corresponds to the
629   // predicted label -- may be negative to index from the end (e.g., -1 for the
630   // last axis).  For example, if axis == 1 and the predictions are
631   // (N x C x H x W), the label blob is expected to contain N*H*W ground truth
632   // labels with integer values in {0, 1, ..., C-1}.
633   optional int32 axis = 2 [default = 1];
634
635   // If specified, ignore instances with the given label.
636   optional int32 ignore_label = 3;
637 }
638
639 message ArgMaxParameter {
640   // If true produce pairs (argmax, maxval)
641   optional bool out_max_val = 1 [default = false];
642   optional uint32 top_k = 2 [default = 1];
643   // The axis along which to maximise -- may be negative to index from the
644   // end (e.g., -1 for the last axis).
645   // By default ArgMaxLayer maximizes over the flattened trailing dimensions
646   // for each index of the first / num dimension.
647   optional int32 axis = 3;
648 }
649
650 message ConcatParameter {
651   // The axis along which to concatenate -- may be negative to index from the
652   // end (e.g., -1 for the last axis).  Other axes must have the
653   // same dimension for all the bottom blobs.
654   // By default, ConcatLayer concatenates blobs along the "channels" axis (1).
655   optional int32 axis = 2 [default = 1];
656
657   // DEPRECATED: alias for "axis" -- does not support negative indexing.
658   optional uint32 concat_dim = 1 [default = 1];
659 }
660
661 message BatchNormParameter {
662   // If false, accumulate global mean/variance values via a moving average. If
663   // true, use those accumulated values instead of computing mean/variance
664   // across the batch.
665   optional bool use_global_stats = 1;
666   // How much does the moving average decay each iteration?
667   optional float moving_average_fraction = 2 [default = .999];
668   // Small value to add to the variance estimate so that we don't divide by
669   // zero.
670   optional float eps = 3 [default = 1e-5];
671 }
672
673 message BiasParameter {
674   // The first axis of bottom[0] (the first input Blob) along which to apply
675   // bottom[1] (the second input Blob).  May be negative to index from the end
676   // (e.g., -1 for the last axis).
677   //
678   // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
679   // top[0] will have the same shape, and bottom[1] may have any of the
680   // following shapes (for the given value of axis):
681   //    (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
682   //    (axis == 1 == -3)          3;     3x40;     3x40x60
683   //    (axis == 2 == -2)                   40;       40x60
684   //    (axis == 3 == -1)                                60
685   // Furthermore, bottom[1] may have the empty shape (regardless of the value of
686   // "axis") -- a scalar bias.
687   optional int32 axis = 1 [default = 1];
688
689   // (num_axes is ignored unless just one bottom is given and the bias is
690   // a learned parameter of the layer.  Otherwise, num_axes is determined by the
691   // number of axes by the second bottom.)
692   // The number of axes of the input (bottom[0]) covered by the bias
693   // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
694   // Set num_axes := 0, to add a zero-axis Blob: a scalar.
695   optional int32 num_axes = 2 [default = 1];
696
697   // (filler is ignored unless just one bottom is given and the bias is
698   // a learned parameter of the layer.)
699   // The initialization for the learned bias parameter.
700   // Default is the zero (0) initialization, resulting in the BiasLayer
701   // initially performing the identity operation.
702   optional FillerParameter filler = 3;
703 }
704
705 message ContrastiveLossParameter {
706   // margin for dissimilar pair
707   optional float margin = 1 [default = 1.0];
708   // The first implementation of this cost did not exactly match the cost of
709   // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2.
710   // legacy_version = false (the default) uses (margin - d)^2 as proposed in the
711   // Hadsell paper. New models should probably use this version.
712   // legacy_version = true uses (margin - d^2). This is kept to support /
713   // reproduce existing models and results
714   optional bool legacy_version = 2 [default = false];
715 }
716
717 message ConvolutionParameter {
718   optional uint32 num_output = 1; // The number of outputs for the layer
719   optional bool bias_term = 2 [default = true]; // whether to have bias terms
720
721   // Pad, kernel size, and stride are all given as a single value for equal
722   // dimensions in all spatial dimensions, or once per spatial dimension.
723   repeated uint32 pad = 3; // The padding size; defaults to 0
724   repeated uint32 kernel_size = 4; // The kernel size
725   repeated uint32 stride = 6; // The stride; defaults to 1
726   // Factor used to dilate the kernel, (implicitly) zero-filling the resulting
727   // holes. (Kernel dilation is sometimes referred to by its use in the
728   // algorithme Ã  trous from Holschneider et al. 1987.)
729   repeated uint32 dilation = 18; // The dilation; defaults to 1
730
731   // For 2D convolution only, the *_h and *_w versions may also be used to
732   // specify both spatial dimensions.
733   optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only)
734   optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only)
735   optional uint32 kernel_h = 11; // The kernel height (2D only)
736   optional uint32 kernel_w = 12; // The kernel width (2D only)
737   optional uint32 stride_h = 13; // The stride height (2D only)
738   optional uint32 stride_w = 14; // The stride width (2D only)
739
740   optional uint32 group = 5 [default = 1]; // The group size for group conv
741
742   optional FillerParameter weight_filler = 7; // The filler for the weight
743   optional FillerParameter bias_filler = 8; // The filler for the bias
744   enum Engine {
745     DEFAULT = 0;
746     CAFFE = 1;
747     CUDNN = 2;
748   }
749   optional Engine engine = 15 [default = DEFAULT];
750
751   // The axis to interpret as "channels" when performing convolution.
752   // Preceding dimensions are treated as independent inputs;
753   // succeeding dimensions are treated as "spatial".
754   // With (N, C, H, W) inputs, and axis == 1 (the default), we perform
755   // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for
756   // groups g>1) filters across the spatial axes (H, W) of the input.
757   // With (N, C, D, H, W) inputs, and axis == 1, we perform
758   // N independent 3D convolutions, sliding (C/g)-channels
759   // filters across the spatial axes (D, H, W) of the input.
760   optional int32 axis = 16 [default = 1];
761
762   // Whether to force use of the general ND convolution, even if a specific
763   // implementation for blobs of the appropriate number of spatial dimensions
764   // is available. (Currently, there is only a 2D-specific convolution
765   // implementation; for input blobs with num_axes != 2, this option is
766   // ignored and the ND implementation will be used.)
767   optional bool force_nd_im2col = 17 [default = false];
768 }
769
770 message CropParameter {
771   // To crop, elements of the first bottom are selected to fit the dimensions
772   // of the second, reference bottom. The crop is configured by
773   // - the crop `axis` to pick the dimensions for cropping
774   // - the crop `offset` to set the shift for all/each dimension
775   // to align the cropped bottom with the reference bottom.
776   // All dimensions up to but excluding `axis` are preserved, while
777   // the dimensions including and trailing `axis` are cropped.
778   // If only one `offset` is set, then all dimensions are offset by this amount.
779   // Otherwise, the number of offsets must equal the number of cropped axes to
780   // shift the crop in each dimension accordingly.
781   // Note: standard dimensions are N,C,H,W so the default is a spatial crop,
782   // and `axis` may be negative to index from the end (e.g., -1 for the last
783   // axis).
784   optional int32 axis = 1 [default = 2];
785   repeated uint32 offset = 2;
786 }
787
788 message DataParameter {
789   enum DB {
790     LEVELDB = 0;
791     LMDB = 1;
792   }
793   // Specify the data source.
794   optional string source = 1;
795   // Specify the batch size.
796   optional uint32 batch_size = 4;
797   // The rand_skip variable is for the data layer to skip a few data points
798   // to avoid all asynchronous sgd clients to start at the same point. The skip
799   // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
800   // be larger than the number of keys in the database.
801   // DEPRECATED. Each solver accesses a different subset of the database.
802   optional uint32 rand_skip = 7 [default = 0];
803   optional DB backend = 8 [default = LEVELDB];
804   // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
805   // simple scaling and subtracting the data mean, if provided. Note that the
806   // mean subtraction is always carried out before scaling.
807   optional float scale = 2 [default = 1];
808   optional string mean_file = 3;
809   // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
810   // crop an image.
811   optional uint32 crop_size = 5 [default = 0];
812   // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
813   // data.
814   optional bool mirror = 6 [default = false];
815   // Force the encoded image to have 3 color channels
816   optional bool force_encoded_color = 9 [default = false];
817   // Prefetch queue (Number of batches to prefetch to host memory, increase if
818   // data access bandwidth varies).
819   optional uint32 prefetch = 10 [default = 4];
820 }
821
822 message NonMaximumSuppressionParameter {
823   // Threshold to be used in nms.
824   optional float nms_threshold = 1 [default = 0.3];
825   // Maximum number of results to be kept.
826   optional int32 top_k = 2;
827   // Parameter for adaptive nms.
828   optional float eta = 3 [default = 1.0];
829 }
830
831 message SaveOutputParameter {
832   // Output directory. If not empty, we will save the results.
833   optional string output_directory = 1;
834   // Output name prefix.
835   optional string output_name_prefix = 2;
836   // Output format.
837   //    VOC - PASCAL VOC output format.
838   //    COCO - MS COCO output format.
839   optional string output_format = 3;
840   // If you want to output results, must also provide the following two files.
841   // Otherwise, we will ignore saving results.
842   // label map file.
843   optional string label_map_file = 4;
844   // A file which contains a list of names and sizes with same order
845   // of the input DB. The file is in the following format:
846   //    name height width
847   //    ...
848   optional string name_size_file = 5;
849   // Number of test images. It can be less than the lines specified in
850   // name_size_file. For example, when we only want to evaluate on part
851   // of the test images.
852   optional uint32 num_test_image = 6;
853 }
854
855 message DropoutParameter {
856   optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio
857 }
858
859 // DummyDataLayer fills any number of arbitrarily shaped blobs with random
860 // (or constant) data generated by "Fillers" (see "message FillerParameter").
861 message DummyDataParameter {
862   // This layer produces N >= 1 top blobs.  DummyDataParameter must specify 1 or N
863   // shape fields, and 0, 1 or N data_fillers.
864   //
865   // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used.
866   // If 1 data_filler is specified, it is applied to all top blobs.  If N are
867   // specified, the ith is applied to the ith top blob.
868   repeated FillerParameter data_filler = 1;
869   repeated BlobShape shape = 6;
870
871   // 4D dimensions -- deprecated.  Use "shape" instead.
872   repeated uint32 num = 2;
873   repeated uint32 channels = 3;
874   repeated uint32 height = 4;
875   repeated uint32 width = 5;
876 }
877
878 message EltwiseParameter {
879   enum EltwiseOp {
880     PROD = 0;
881     SUM = 1;
882     MAX = 2;
883   }
884   optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation
885   repeated float coeff = 2; // blob-wise coefficient for SUM operation
886
887   // Whether to use an asymptotically slower (for >2 inputs) but stabler method
888   // of computing the gradient for the PROD operation. (No effect for SUM op.)
889   optional bool stable_prod_grad = 3 [default = true];
890 }
891
892 // Message that stores parameters used by ELULayer
893 message ELUParameter {
894   // Described in:
895   // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate
896   // Deep Network Learning by Exponential Linear Units (ELUs). arXiv
897   optional float alpha = 1 [default = 1];
898 }
899
900 // Message that stores parameters used by EmbedLayer
901 message EmbedParameter {
902   optional uint32 num_output = 1; // The number of outputs for the layer
903   // The input is given as integers to be interpreted as one-hot
904   // vector indices with dimension num_input.  Hence num_input should be
905   // 1 greater than the maximum possible input value.
906   optional uint32 input_dim = 2;
907
908   optional bool bias_term = 3 [default = true]; // Whether to use a bias term
909   optional FillerParameter weight_filler = 4; // The filler for the weight
910   optional FillerParameter bias_filler = 5; // The filler for the bias
911
912 }
913
914 // Message that stores parameters used by ExpLayer
915 message ExpParameter {
916   // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0.
917   // Or if base is set to the default (-1), base is set to e,
918   // so y = exp(shift + scale * x).
919   optional float base = 1 [default = -1.0];
920   optional float scale = 2 [default = 1.0];
921   optional float shift = 3 [default = 0.0];
922 }
923
924 /// Message that stores parameters used by FlattenLayer
925 message FlattenParameter {
926   // The first axis to flatten: all preceding axes are retained in the output.
927   // May be negative to index from the end (e.g., -1 for the last axis).
928   optional int32 axis = 1 [default = 1];
929
930   // The last axis to flatten: all following axes are retained in the output.
931   // May be negative to index from the end (e.g., the default -1 for the last
932   // axis).
933   optional int32 end_axis = 2 [default = -1];
934 }
935
936 // Message that stores parameters used by HDF5DataLayer
937 message HDF5DataParameter {
938   // Specify the data source.
939   optional string source = 1;
940   // Specify the batch size.
941   optional uint32 batch_size = 2;
942
943   // Specify whether to shuffle the data.
944   // If shuffle == true, the ordering of the HDF5 files is shuffled,
945   // and the ordering of data within any given HDF5 file is shuffled,
946   // but data between different files are not interleaved; all of a file's
947   // data are output (in a random order) before moving onto another file.
948   optional bool shuffle = 3 [default = false];
949 }
950
951 message HDF5OutputParameter {
952   optional string file_name = 1;
953 }
954
955 message HingeLossParameter {
956   enum Norm {
957     L1 = 1;
958     L2 = 2;
959   }
960   // Specify the Norm to use L1 or L2
961   optional Norm norm = 1 [default = L1];
962 }
963
964 message ImageDataParameter {
965   // Specify the data source.
966   optional string source = 1;
967   // Specify the batch size.
968   optional uint32 batch_size = 4 [default = 1];
969   // The rand_skip variable is for the data layer to skip a few data points
970   // to avoid all asynchronous sgd clients to start at the same point. The skip
971   // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
972   // be larger than the number of keys in the database.
973   optional uint32 rand_skip = 7 [default = 0];
974   // Whether or not ImageLayer should shuffle the list of files at every epoch.
975   optional bool shuffle = 8 [default = false];
976   // It will also resize images if new_height or new_width are not zero.
977   optional uint32 new_height = 9 [default = 0];
978   optional uint32 new_width = 10 [default = 0];
979   // Specify if the images are color or gray
980   optional bool is_color = 11 [default = true];
981   // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
982   // simple scaling and subtracting the data mean, if provided. Note that the
983   // mean subtraction is always carried out before scaling.
984   optional float scale = 2 [default = 1];
985   optional string mean_file = 3;
986   // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
987   // crop an image.
988   optional uint32 crop_size = 5 [default = 0];
989   // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
990   // data.
991   optional bool mirror = 6 [default = false];
992   optional string root_folder = 12 [default = ""];
993 }
994
995 message InfogainLossParameter {
996   // Specify the infogain matrix source.
997   optional string source = 1;
998 }
999
1000 message InnerProductParameter {
1001   optional uint32 num_output = 1; // The number of outputs for the layer
1002   optional bool bias_term = 2 [default = true]; // whether to have bias terms
1003   optional FillerParameter weight_filler = 3; // The filler for the weight
1004   optional FillerParameter bias_filler = 4; // The filler for the bias
1005
1006   // The first axis to be lumped into a single inner product computation;
1007   // all preceding axes are retained in the output.
1008   // May be negative to index from the end (e.g., -1 for the last axis).
1009   optional int32 axis = 5 [default = 1];
1010   // Specify whether to transpose the weight matrix or not.
1011   // If transpose == true, any operations will be performed on the transpose
1012   // of the weight matrix. The weight matrix itself is not going to be transposed
1013   // but rather the transfer flag of operations will be toggled accordingly.
1014   optional bool transpose = 6 [default = false];
1015 }
1016
1017 message InputParameter {
1018   // This layer produces N >= 1 top blob(s) to be assigned manually.
1019   // Define N shapes to set a shape for each top.
1020   // Define 1 shape to set the same shape for every top.
1021   // Define no shape to defer to reshaping manually.
1022   repeated BlobShape shape = 1;
1023 }
1024
1025 // Message that stores parameters used by LogLayer
1026 message LogParameter {
1027   // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0.
1028   // Or if base is set to the default (-1), base is set to e,
1029   // so y = ln(shift + scale * x) = log_e(shift + scale * x)
1030   optional float base = 1 [default = -1.0];
1031   optional float scale = 2 [default = 1.0];
1032   optional float shift = 3 [default = 0.0];
1033 }
1034
1035 // Message that stores parameters used by LRNLayer
1036 message LRNParameter {
1037   optional uint32 local_size = 1 [default = 5];
1038   optional float alpha = 2 [default = 1.];
1039   optional float beta = 3 [default = 0.75];
1040   enum NormRegion {
1041     ACROSS_CHANNELS = 0;
1042     WITHIN_CHANNEL = 1;
1043   }
1044   optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
1045   optional float k = 5 [default = 1.];
1046   enum Engine {
1047     DEFAULT = 0;
1048     CAFFE = 1;
1049     CUDNN = 2;
1050   }
1051   optional Engine engine = 6 [default = DEFAULT];
1052 }
1053
1054 message MemoryDataParameter {
1055   optional uint32 batch_size = 1;
1056   optional uint32 channels = 2;
1057   optional uint32 height = 3;
1058   optional uint32 width = 4;
1059 }
1060
1061 message MVNParameter {
1062   // This parameter can be set to false to normalize mean only
1063   optional bool normalize_variance = 1 [default = true];
1064
1065   // This parameter can be set to true to perform DNN-like MVN
1066   optional bool across_channels = 2 [default = false];
1067
1068   // Epsilon for not dividing by zero while normalizing variance
1069   optional float eps = 3 [default = 1e-9];
1070 }
1071
1072 message ParameterParameter {
1073   optional BlobShape shape = 1;
1074 }
1075
1076 message PoolingParameter {
1077   enum PoolMethod {
1078     MAX = 0;
1079     AVE = 1;
1080     STOCHASTIC = 2;
1081   }
1082   optional PoolMethod pool = 1 [default = MAX]; // The pooling method
1083   // Pad, kernel size, and stride are all given as a single value for equal
1084   // dimensions in height and width or as Y, X pairs.
1085   optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X)
1086   optional uint32 pad_h = 9 [default = 0]; // The padding height
1087   optional uint32 pad_w = 10 [default = 0]; // The padding width
1088   optional uint32 kernel_size = 2; // The kernel size (square)
1089   optional uint32 kernel_h = 5; // The kernel height
1090   optional uint32 kernel_w = 6; // The kernel width
1091   optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X)
1092   optional uint32 stride_h = 7; // The stride height
1093   optional uint32 stride_w = 8; // The stride width
1094   enum Engine {
1095     DEFAULT = 0;
1096     CAFFE = 1;
1097     CUDNN = 2;
1098   }
1099   optional Engine engine = 11 [default = DEFAULT];
1100   // If global_pooling then it will pool over the size of the bottom by doing
1101   // kernel_h = bottom->height and kernel_w = bottom->width
1102   optional bool global_pooling = 12 [default = false];
1103   // Specify floor/ceil mode
1104   // source: https://github.com/BVLC/caffe/pull/3057
1105   optional bool ceil_mode = 13 [default = true];
1106 }
1107
1108 message PowerParameter {
1109   // PowerLayer computes outputs y = (shift + scale * x) ^ power.
1110   optional float power = 1 [default = 1.0];
1111   optional float scale = 2 [default = 1.0];
1112   optional float shift = 3 [default = 0.0];
1113 }
1114
1115 message PythonParameter {
1116   optional string module = 1;
1117   optional string layer = 2;
1118   // This value is set to the attribute `param_str` of the `PythonLayer` object
1119   // in Python before calling the `setup()` method. This could be a number,
1120   // string, dictionary in Python dict format, JSON, etc. You may parse this
1121   // string in `setup` method and use it in `forward` and `backward`.
1122   optional string param_str = 3 [default = ''];
1123   // Whether this PythonLayer is shared among worker solvers during data parallelism.
1124   // If true, each worker solver sequentially run forward from this layer.
1125   // This value should be set true if you are using it as a data layer.
1126   optional bool share_in_parallel = 4 [default = false];
1127 }
1128
1129 // Message that stores parameters used by RecurrentLayer
1130 message RecurrentParameter {
1131   // The dimension of the output (and usually hidden state) representation --
1132   // must be explicitly set to non-zero.
1133   optional uint32 num_output = 1 [default = 0];
1134
1135   optional FillerParameter weight_filler = 2; // The filler for the weight
1136   optional FillerParameter bias_filler = 3; // The filler for the bias
1137
1138   // Whether to enable displaying debug_info in the unrolled recurrent net.
1139   optional bool debug_info = 4 [default = false];
1140
1141   // Whether to add as additional inputs (bottoms) the initial hidden state
1142   // blobs, and add as additional outputs (tops) the final timestep hidden state
1143   // blobs.  The number of additional bottom/top blobs required depends on the
1144   // recurrent architecture -- e.g., 1 for RNNs, 2 for LSTMs.
1145   optional bool expose_hidden = 5 [default = false];
1146 }
1147
1148 // Message that stores parameters used by ReductionLayer
1149 message ReductionParameter {
1150   enum ReductionOp {
1151     SUM = 1;
1152     ASUM = 2;
1153     SUMSQ = 3;
1154     MEAN = 4;
1155   }
1156
1157   optional ReductionOp operation = 1 [default = SUM]; // reduction operation
1158
1159   // The first axis to reduce to a scalar -- may be negative to index from the
1160   // end (e.g., -1 for the last axis).
1161   // (Currently, only reduction along ALL "tail" axes is supported; reduction
1162   // of axis M through N, where N < num_axes - 1, is unsupported.)
1163   // Suppose we have an n-axis bottom Blob with shape:
1164   //     (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)).
1165   // If axis == m, the output Blob will have shape
1166   //     (d0, d1, d2, ..., d(m-1)),
1167   // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1))
1168   // times, each including (dm * d(m+1) * ... * d(n-1)) individual data.
1169   // If axis == 0 (the default), the output Blob always has the empty shape
1170   // (count 1), performing reduction across the entire input --
1171   // often useful for creating new loss functions.
1172   optional int32 axis = 2 [default = 0];
1173
1174   optional float coeff = 3 [default = 1.0]; // coefficient for output
1175 }
1176
1177 // Message that stores parameters used by ReLULayer
1178 message ReLUParameter {
1179   // Allow non-zero slope for negative inputs to speed up optimization
1180   // Described in:
1181   // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities
1182   // improve neural network acoustic models. In ICML Workshop on Deep Learning
1183   // for Audio, Speech, and Language Processing.
1184   optional float negative_slope = 1 [default = 0];
1185   enum Engine {
1186     DEFAULT = 0;
1187     CAFFE = 1;
1188     CUDNN = 2;
1189   }
1190   optional Engine engine = 2 [default = DEFAULT];
1191 }
1192
1193 message ReshapeParameter {
1194   // Specify the output dimensions. If some of the dimensions are set to 0,
1195   // the corresponding dimension from the bottom layer is used (unchanged).
1196   // Exactly one dimension may be set to -1, in which case its value is
1197   // inferred from the count of the bottom blob and the remaining dimensions.
1198   // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8:
1199   //
1200   //   layer {
1201   //     type: "Reshape" bottom: "input" top: "output"
1202   //     reshape_param { ... }
1203   //   }
1204   //
1205   // If "input" is 2D with shape 2 x 8, then the following reshape_param
1206   // specifications are all equivalent, producing a 3D blob "output" with shape
1207   // 2 x 2 x 4:
1208   //
1209   //   reshape_param { shape { dim:  2  dim: 2  dim:  4 } }
1210   //   reshape_param { shape { dim:  0  dim: 2  dim:  4 } }
1211   //   reshape_param { shape { dim:  0  dim: 2  dim: -1 } }
1212   //   reshape_param { shape { dim:  0  dim:-1  dim:  4 } }
1213   //
1214   optional BlobShape shape = 1;
1215
1216   // axis and num_axes control the portion of the bottom blob's shape that are
1217   // replaced by (included in) the reshape. By default (axis == 0 and
1218   // num_axes == -1), the entire bottom blob shape is included in the reshape,
1219   // and hence the shape field must specify the entire output shape.
1220   //
1221   // axis may be non-zero to retain some portion of the beginning of the input
1222   // shape (and may be negative to index from the end; e.g., -1 to begin the
1223   // reshape after the last axis, including nothing in the reshape,
1224   // -2 to include only the last axis, etc.).
1225   //
1226   // For example, suppose "input" is a 2D blob with shape 2 x 8.
1227   // Then the following ReshapeLayer specifications are all equivalent,
1228   // producing a blob "output" with shape 2 x 2 x 4:
1229   //
1230   //   reshape_param { shape { dim: 2  dim: 2  dim: 4 } }
1231   //   reshape_param { shape { dim: 2  dim: 4 } axis:  1 }
1232   //   reshape_param { shape { dim: 2  dim: 4 } axis: -3 }
1233   //
1234   // num_axes specifies the extent of the reshape.
1235   // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on
1236   // input axes in the range [axis, axis+num_axes].
1237   // num_axes may also be -1, the default, to include all remaining axes
1238   // (starting from axis).
1239   //
1240   // For example, suppose "input" is a 2D blob with shape 2 x 8.
1241   // Then the following ReshapeLayer specifications are equivalent,
1242   // producing a blob "output" with shape 1 x 2 x 8.
1243   //
1244   //   reshape_param { shape { dim:  1  dim: 2  dim:  8 } }
1245   //   reshape_param { shape { dim:  1  dim: 2  }  num_axes: 1 }
1246   //   reshape_param { shape { dim:  1  }  num_axes: 0 }
1247   //
1248   // On the other hand, these would produce output blob shape 2 x 1 x 8:
1249   //
1250   //   reshape_param { shape { dim: 2  dim: 1  dim: 8  }  }
1251   //   reshape_param { shape { dim: 1 }  axis: 1  num_axes: 0 }
1252   //
1253   optional int32 axis = 2 [default = 0];
1254   optional int32 num_axes = 3 [default = -1];
1255 }
1256
1257 message ScaleParameter {
1258   // The first axis of bottom[0] (the first input Blob) along which to apply
1259   // bottom[1] (the second input Blob).  May be negative to index from the end
1260   // (e.g., -1 for the last axis).
1261   //
1262   // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
1263   // top[0] will have the same shape, and bottom[1] may have any of the
1264   // following shapes (for the given value of axis):
1265   //    (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
1266   //    (axis == 1 == -3)          3;     3x40;     3x40x60
1267   //    (axis == 2 == -2)                   40;       40x60
1268   //    (axis == 3 == -1)                                60
1269   // Furthermore, bottom[1] may have the empty shape (regardless of the value of
1270   // "axis") -- a scalar multiplier.
1271   optional int32 axis = 1 [default = 1];
1272
1273   // (num_axes is ignored unless just one bottom is given and the scale is
1274   // a learned parameter of the layer.  Otherwise, num_axes is determined by the
1275   // number of axes by the second bottom.)
1276   // The number of axes of the input (bottom[0]) covered by the scale
1277   // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
1278   // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar.
1279   optional int32 num_axes = 2 [default = 1];
1280
1281   // (filler is ignored unless just one bottom is given and the scale is
1282   // a learned parameter of the layer.)
1283   // The initialization for the learned scale parameter.
1284   // Default is the unit (1) initialization, resulting in the ScaleLayer
1285   // initially performing the identity operation.
1286   optional FillerParameter filler = 3;
1287
1288   // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but
1289   // may be more efficient).  Initialized with bias_filler (defaults to 0).
1290   optional bool bias_term = 4 [default = false];
1291   optional FillerParameter bias_filler = 5;
1292 }
1293
1294 message SigmoidParameter {
1295   enum Engine {
1296     DEFAULT = 0;
1297     CAFFE = 1;
1298     CUDNN = 2;
1299   }
1300   optional Engine engine = 1 [default = DEFAULT];
1301 }
1302
1303 message SliceParameter {
1304   // The axis along which to slice -- may be negative to index from the end
1305   // (e.g., -1 for the last axis).
1306   // By default, SliceLayer concatenates blobs along the "channels" axis (1).
1307   optional int32 axis = 3 [default = 1];
1308   repeated uint32 slice_point = 2;
1309
1310   // DEPRECATED: alias for "axis" -- does not support negative indexing.
1311   optional uint32 slice_dim = 1 [default = 1];
1312 }
1313
1314 // Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer
1315 message SoftmaxParameter {
1316   enum Engine {
1317     DEFAULT = 0;
1318     CAFFE = 1;
1319     CUDNN = 2;
1320   }
1321   optional Engine engine = 1 [default = DEFAULT];
1322
1323   // The axis along which to perform the softmax -- may be negative to index
1324   // from the end (e.g., -1 for the last axis).
1325   // Any other axes will be evaluated as independent softmaxes.
1326   optional int32 axis = 2 [default = 1];
1327 }
1328
1329 message TanHParameter {
1330   enum Engine {
1331     DEFAULT = 0;
1332     CAFFE = 1;
1333     CUDNN = 2;
1334   }
1335   optional Engine engine = 1 [default = DEFAULT];
1336 }
1337
1338 // Message that stores parameters used by TileLayer
1339 message TileParameter {
1340   // The index of the axis to tile.
1341   optional int32 axis = 1 [default = 1];
1342
1343   // The number of copies (tiles) of the blob to output.
1344   optional int32 tiles = 2;
1345 }
1346
1347 // Message that stores parameters used by ThresholdLayer
1348 message ThresholdParameter {
1349   optional float threshold = 1 [default = 0]; // Strictly positive values
1350 }
1351
1352 message WindowDataParameter {
1353   // Specify the data source.
1354   optional string source = 1;
1355   // For data pre-processing, we can do simple scaling and subtracting the
1356   // data mean, if provided. Note that the mean subtraction is always carried
1357   // out before scaling.
1358   optional float scale = 2 [default = 1];
1359   optional string mean_file = 3;
1360   // Specify the batch size.
1361   optional uint32 batch_size = 4;
1362   // Specify if we would like to randomly crop an image.
1363   optional uint32 crop_size = 5 [default = 0];
1364   // Specify if we want to randomly mirror data.
1365   optional bool mirror = 6 [default = false];
1366   // Foreground (object) overlap threshold
1367   optional float fg_threshold = 7 [default = 0.5];
1368   // Background (non-object) overlap threshold
1369   optional float bg_threshold = 8 [default = 0.5];
1370   // Fraction of batch that should be foreground objects
1371   optional float fg_fraction = 9 [default = 0.25];
1372   // Amount of contextual padding to add around a window
1373   // (used only by the window_data_layer)
1374   optional uint32 context_pad = 10 [default = 0];
1375   // Mode for cropping out a detection window
1376   // warp: cropped window is warped to a fixed size and aspect ratio
1377   // square: the tightest square around the window is cropped
1378   optional string crop_mode = 11 [default = "warp"];
1379   // cache_images: will load all images in memory for faster access
1380   optional bool cache_images = 12 [default = false];
1381   // append root_folder to locate images
1382   optional string root_folder = 13 [default = ""];
1383 }
1384
1385 message SPPParameter {
1386   enum PoolMethod {
1387     MAX = 0;
1388     AVE = 1;
1389     STOCHASTIC = 2;
1390   }
1391   optional uint32 pyramid_height = 1;
1392   optional PoolMethod pool = 2 [default = MAX]; // The pooling method
1393   enum Engine {
1394     DEFAULT = 0;
1395     CAFFE = 1;
1396     CUDNN = 2;
1397   }
1398   optional Engine engine = 6 [default = DEFAULT];
1399 }
1400
1401 // DEPRECATED: use LayerParameter.
1402 message V1LayerParameter {
1403   repeated string bottom = 2;
1404   repeated string top = 3;
1405   optional string name = 4;
1406   repeated NetStateRule include = 32;
1407   repeated NetStateRule exclude = 33;
1408   enum LayerType {
1409     NONE = 0;
1410     ABSVAL = 35;
1411     ACCURACY = 1;
1412     ARGMAX = 30;
1413     BNLL = 2;
1414     CONCAT = 3;
1415     CONTRASTIVE_LOSS = 37;
1416     CONVOLUTION = 4;
1417     DATA = 5;
1418     DECONVOLUTION = 39;
1419     DROPOUT = 6;
1420     DUMMY_DATA = 32;
1421     EUCLIDEAN_LOSS = 7;
1422     ELTWISE = 25;
1423     EXP = 38;
1424     FLATTEN = 8;
1425     HDF5_DATA = 9;
1426     HDF5_OUTPUT = 10;
1427     HINGE_LOSS = 28;
1428     IM2COL = 11;
1429     IMAGE_DATA = 12;
1430     INFOGAIN_LOSS = 13;
1431     INNER_PRODUCT = 14;
1432     LRN = 15;
1433     MEMORY_DATA = 29;
1434     MULTINOMIAL_LOGISTIC_LOSS = 16;
1435     MVN = 34;
1436     POOLING = 17;
1437     POWER = 26;
1438     RELU = 18;
1439     SIGMOID = 19;
1440     SIGMOID_CROSS_ENTROPY_LOSS = 27;
1441     SILENCE = 36;
1442     SOFTMAX = 20;
1443     SOFTMAX_LOSS = 21;
1444     SPLIT = 22;
1445     SLICE = 33;
1446     TANH = 23;
1447     WINDOW_DATA = 24;
1448     THRESHOLD = 31;
1449   }
1450   optional LayerType type = 5;
1451   repeated BlobProto blobs = 6;
1452   repeated string param = 1001;
1453   repeated DimCheckMode blob_share_mode = 1002;
1454   enum DimCheckMode {
1455     STRICT = 0;
1456     PERMISSIVE = 1;
1457   }
1458   repeated float blobs_lr = 7;
1459   repeated float weight_decay = 8;
1460   repeated float loss_weight = 35;
1461   optional AccuracyParameter accuracy_param = 27;
1462   optional ArgMaxParameter argmax_param = 23;
1463   optional ConcatParameter concat_param = 9;
1464   optional ContrastiveLossParameter contrastive_loss_param = 40;
1465   optional ConvolutionParameter convolution_param = 10;
1466   optional DataParameter data_param = 11;
1467   optional DropoutParameter dropout_param = 12;
1468   optional DummyDataParameter dummy_data_param = 26;
1469   optional EltwiseParameter eltwise_param = 24;
1470   optional ExpParameter exp_param = 41;
1471   optional HDF5DataParameter hdf5_data_param = 13;
1472   optional HDF5OutputParameter hdf5_output_param = 14;
1473   optional HingeLossParameter hinge_loss_param = 29;
1474   optional ImageDataParameter image_data_param = 15;
1475   optional InfogainLossParameter infogain_loss_param = 16;
1476   optional InnerProductParameter inner_product_param = 17;
1477   optional LRNParameter lrn_param = 18;
1478   optional MemoryDataParameter memory_data_param = 22;
1479   optional MVNParameter mvn_param = 34;
1480   optional PoolingParameter pooling_param = 19;
1481   optional PowerParameter power_param = 21;
1482   optional ReLUParameter relu_param = 30;
1483   optional SigmoidParameter sigmoid_param = 38;
1484   optional SoftmaxParameter softmax_param = 39;
1485   optional SliceParameter slice_param = 31;
1486   optional TanHParameter tanh_param = 37;
1487   optional ThresholdParameter threshold_param = 25;
1488   optional WindowDataParameter window_data_param = 20;
1489   optional TransformationParameter transform_param = 36;
1490   optional LossParameter loss_param = 42;
1491   optional V0LayerParameter layer = 1;
1492 }
1493
1494 // DEPRECATED: V0LayerParameter is the old way of specifying layer parameters
1495 // in Caffe.  We keep this message type around for legacy support.
1496 message V0LayerParameter {
1497   optional string name = 1; // the layer name
1498   optional string type = 2; // the string to specify the layer type
1499
1500   // Parameters to specify layers with inner products.
1501   optional uint32 num_output = 3; // The number of outputs for the layer
1502   optional bool biasterm = 4 [default = true]; // whether to have bias terms
1503   optional FillerParameter weight_filler = 5; // The filler for the weight
1504   optional FillerParameter bias_filler = 6; // The filler for the bias
1505
1506   optional uint32 pad = 7 [default = 0]; // The padding size
1507   optional uint32 kernelsize = 8; // The kernel size
1508   optional uint32 group = 9 [default = 1]; // The group size for group conv
1509   optional uint32 stride = 10 [default = 1]; // The stride
1510   enum PoolMethod {
1511     MAX = 0;
1512     AVE = 1;
1513     STOCHASTIC = 2;
1514   }
1515   optional PoolMethod pool = 11 [default = MAX]; // The pooling method
1516   optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio
1517
1518   optional uint32 local_size = 13 [default = 5]; // for local response norm
1519   optional float alpha = 14 [default = 1.]; // for local response norm
1520   optional float beta = 15 [default = 0.75]; // for local response norm
1521   optional float k = 22 [default = 1.];
1522
1523   // For data layers, specify the data source
1524   optional string source = 16;
1525   // For data pre-processing, we can do simple scaling and subtracting the
1526   // data mean, if provided. Note that the mean subtraction is always carried
1527   // out before scaling.
1528   optional float scale = 17 [default = 1];
1529   optional string meanfile = 18;
1530   // For data layers, specify the batch size.
1531   optional uint32 batchsize = 19;
1532   // For data layers, specify if we would like to randomly crop an image.
1533   optional uint32 cropsize = 20 [default = 0];
1534   // For data layers, specify if we want to randomly mirror data.
1535   optional bool mirror = 21 [default = false];
1536
1537   // The blobs containing the numeric parameters of the layer
1538   repeated BlobProto blobs = 50;
1539   // The ratio that is multiplied on the global learning rate. If you want to
1540   // set the learning ratio for one blob, you need to set it for all blobs.
1541   repeated float blobs_lr = 51;
1542   // The weight decay that is multiplied on the global weight decay.
1543   repeated float weight_decay = 52;
1544
1545   // The rand_skip variable is for the data layer to skip a few data points
1546   // to avoid all asynchronous sgd clients to start at the same point. The skip
1547   // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
1548   // be larger than the number of keys in the database.
1549   optional uint32 rand_skip = 53 [default = 0];
1550
1551   // Fields related to detection (det_*)
1552   // foreground (object) overlap threshold
1553   optional float det_fg_threshold = 54 [default = 0.5];
1554   // background (non-object) overlap threshold
1555   optional float det_bg_threshold = 55 [default = 0.5];
1556   // Fraction of batch that should be foreground objects
1557   optional float det_fg_fraction = 56 [default = 0.25];
1558
1559   // optional bool OBSOLETE_can_clobber = 57 [default = true];
1560
1561   // Amount of contextual padding to add around a window
1562   // (used only by the window_data_layer)
1563   optional uint32 det_context_pad = 58 [default = 0];
1564
1565   // Mode for cropping out a detection window
1566   // warp: cropped window is warped to a fixed size and aspect ratio
1567   // square: the tightest square around the window is cropped
1568   optional string det_crop_mode = 59 [default = "warp"];
1569
1570   // For ReshapeLayer, one needs to specify the new dimensions.
1571   optional int32 new_num = 60 [default = 0];
1572   optional int32 new_channels = 61 [default = 0];
1573   optional int32 new_height = 62 [default = 0];
1574   optional int32 new_width = 63 [default = 0];
1575
1576   // Whether or not ImageLayer should shuffle the list of files at every epoch.
1577   // It will also resize images if new_height or new_width are not zero.
1578   optional bool shuffle_images = 64 [default = false];
1579
1580   // For ConcatLayer, one needs to specify the dimension for concatenation, and
1581   // the other dimensions must be the same for all the bottom blobs.
1582   // By default it will concatenate blobs along the channels dimension.
1583   optional uint32 concat_dim = 65 [default = 1];
1584
1585   optional HDF5OutputParameter hdf5_output_param = 1001;
1586 }
1587
1588 message PReLUParameter {
1589   // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers:
1590   // Surpassing Human-Level Performance on ImageNet Classification, 2015.
1591
1592   // Initial value of a_i. Default is a_i=0.25 for all i.
1593   optional FillerParameter filler = 1;
1594   // Whether or not slope parameters are shared across channels.
1595   optional bool channel_shared = 2 [default = false];
1596 }
1597
1598 // The normalized bounding box [0, 1] w.r.t. the input image size.
1599 message NormalizedBBox {
1600   optional float xmin = 1;
1601   optional float ymin = 2;
1602   optional float xmax = 3;
1603   optional float ymax = 4;
1604   optional int32 label = 5;
1605   optional bool difficult = 6;
1606   optional float score = 7;
1607   optional float size = 8;
1608 }
1609
1610 // origin: https://github.com/rbgirshick/caffe-fast-rcnn/tree/fast-rcnn
1611 // Message that stores parameters used by ROIPoolingLayer
1612 message ROIPoolingParameter {
1613   // Pad, kernel size, and stride are all given as a single value for equal
1614   // dimensions in height and width or as Y, X pairs.
1615   optional uint32 pooled_h = 1 [default = 0]; // The pooled output height
1616   optional uint32 pooled_w = 2 [default = 0]; // The pooled output width
1617   // Multiplicative spatial scale factor to translate ROI coords from their
1618   // input scale to the scale used when pooling
1619   optional float spatial_scale = 3 [default = 1];
1620 }