1 /*M///////////////////////////////////////////////////////////////////////////////////////
4 //All contributions by the University of California:
5 //Copyright (c) 2014, The Regents of the University of California (Regents)
8 //All other contributions:
9 //Copyright (c) 2014, the respective contributors
10 //All rights reserved.
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
21 //Redistribution and use in source and binary forms, with or without
22 //modification, are permitted provided that the following conditions are met:
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.
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.
41 //CONTRIBUTION AGREEMENT
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.
53 // NVidia's Caffe feature is used to store fp16 weights, https://github.com/NVIDIA/caffe:
54 // Math and storage types
59 INT = 3; // math not supported
60 UINT = 4; // math not supported
63 // Specifies the shape (dimensions) of a Blob.
65 repeated int64 dim = 1 [packed = true];
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];
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.
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];
87 // The BlobProtoVector is simply a way to pass multiple blobproto instances
89 message BlobProtoVector {
90 repeated BlobProto blobs = 1;
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;
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];
111 // Message that store parameters used by PriorBoxLayer
112 message PriorBoxParameter {
113 // Encode/decode type.
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
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;
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,
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;
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];
197 message FillerParameter {
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.
215 optional VarianceNorm variance_norm = 8 [default = FAN_IN];
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;
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;
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;
240 // Print debugging information about results while running Net::Forward,
241 // Net::Backward, and Net::Update.
242 optional bool debug_info = 7 [default = false];
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.
248 // DEPRECATED: use 'layer' instead.
249 repeated V1LayerParameter layers = 2;
253 // Update the next available ID when you add a new SolverParameter field.
255 // SolverParameter next available ID: 41 (last added: type)
256 message SolverParameter {
257 //////////////////////////////////////////////////////////////////////////////
258 // Specifying the train and test networks
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 //////////////////////////////////////////////////////////////////////////////
271 // Proto filename for the train net, possibly combined with one or more
273 optional string net = 24;
274 // Inline train net param, possibly combined with one or more test nets.
275 optional NetParameter net_param = 25;
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.
282 // The states for the train/test nets. Must be unspecified or
283 // specified once per net.
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;
292 // The number of iterations for each test net.
293 repeated int32 test_iter = 3;
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];
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
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))))
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;
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];
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 {
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.
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];
366 // type of the solver
367 optional string type = 40 [default = "SGD"];
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];
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];
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];
382 // If false, don't save a snapshot after training finishes.
383 optional bool snapshot_after_train = 28 [default = true];
385 // DEPRECATED: old solver enum types, use string instead
394 // DEPRECATED: use type instead of solver_type
395 optional SolverType solver_type = 30 [default = SGD];
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
412 optional Phase phase = 1 [default = TEST];
413 optional int32 level = 2 [default = 0];
414 repeated string stage = 3;
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;
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;
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;
435 // Specifies training parameters (multipliers on global learning constants,
436 // and the name and other settings used for weight sharing).
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;
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;
447 // STRICT (default) requires that num, channels, height, width each match.
449 // PERMISSIVE requires only the count (num*channels*height*width) to match.
453 // The multiplier on the global learning rate for this parameter.
454 optional float lr_mult = 3 [default = 1.0];
456 // The multiplier on the global weight decay for this parameter.
457 optional float decay_mult = 4 [default = 1.0];
461 // Update the next available ID when you add a new LayerParameter field.
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
470 // The train / test phase for computation.
471 optional Phase phase = 10;
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,
476 repeated float loss_weight = 5;
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;
482 // The blobs containing the numeric parameters of the layer.
483 repeated BlobProto blobs = 7;
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.
491 // The size must be either 0 or equal to the number of bottoms.
492 repeated bool propagate_down = 11;
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;
503 // Parameters for data pre-processing.
504 optional TransformationParameter transform_param = 100;
506 // Parameters shared by loss layers.
507 optional LossParameter loss_param = 101;
509 // Layer type-specific parameters.
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 ProposalParameter proposal_param = 201;
551 optional PythonParameter python_param = 130;
552 optional RecurrentParameter recurrent_param = 146;
553 optional ReductionParameter reduction_param = 136;
554 optional ReLUParameter relu_param = 123;
555 optional ReshapeParameter reshape_param = 133;
556 optional ROIPoolingParameter roi_pooling_param = 8266711; // https://github.com/rbgirshick/caffe-fast-rcnn/tree/fast-rcnn
557 optional ScaleParameter scale_param = 142;
558 optional SigmoidParameter sigmoid_param = 124;
559 optional SoftmaxParameter softmax_param = 125;
560 optional SPPParameter spp_param = 132;
561 optional SliceParameter slice_param = 126;
562 optional TanHParameter tanh_param = 127;
563 optional ThresholdParameter threshold_param = 128;
564 optional TileParameter tile_param = 138;
565 optional WindowDataParameter window_data_param = 129;
568 // Message that stores parameters used to apply transformation
569 // to the data layer's data
570 message TransformationParameter {
571 // For data pre-processing, we can do simple scaling and subtracting the
572 // data mean, if provided. Note that the mean subtraction is always carried
573 // out before scaling.
574 optional float scale = 1 [default = 1];
575 // Specify if we want to randomly mirror data.
576 optional bool mirror = 2 [default = false];
577 // Specify if we would like to randomly crop an image.
578 optional uint32 crop_size = 3 [default = 0];
579 // mean_file and mean_value cannot be specified at the same time
580 optional string mean_file = 4;
581 // if specified can be repeated once (would subtract it from all the channels)
582 // or can be repeated the same number of times as channels
583 // (would subtract them from the corresponding channel)
584 repeated float mean_value = 5;
585 // Force the decoded image to have 3 color channels.
586 optional bool force_color = 6 [default = false];
587 // Force the decoded image to have 1 color channels.
588 optional bool force_gray = 7 [default = false];
591 // Message that stores parameters shared by loss layers
592 message LossParameter {
593 // If specified, ignore instances with the given label.
594 optional int32 ignore_label = 1;
595 // How to normalize the loss for loss layers that aggregate across batches,
596 // spatial dimensions, or other dimensions. Currently only implemented in
597 // SoftmaxWithLoss and SigmoidCrossEntropyLoss layers.
598 enum NormalizationMode {
599 // Divide by the number of examples in the batch times spatial dimensions.
600 // Outputs that receive the ignore label will NOT be ignored in computing
601 // the normalization factor.
603 // Divide by the total number of output locations that do not take the
604 // ignore_label. If ignore_label is not set, this behaves like FULL.
606 // Divide by the batch size.
608 // Do not normalize the loss.
611 // For historical reasons, the default normalization for
612 // SigmoidCrossEntropyLoss is BATCH_SIZE and *not* VALID.
613 optional NormalizationMode normalization = 3 [default = VALID];
614 // Deprecated. Ignored if normalization is specified. If normalization
615 // is not specified, then setting this to false will be equivalent to
616 // normalization = BATCH_SIZE to be consistent with previous behavior.
617 optional bool normalize = 2;
620 // Messages that store parameters used by individual layer types follow, in
621 // alphabetical order.
623 message AccuracyParameter {
624 // When computing accuracy, count as correct by comparing the true label to
625 // the top k scoring classes. By default, only compare to the top scoring
626 // class (i.e. argmax).
627 optional uint32 top_k = 1 [default = 1];
629 // The "label" axis of the prediction blob, whose argmax corresponds to the
630 // predicted label -- may be negative to index from the end (e.g., -1 for the
631 // last axis). For example, if axis == 1 and the predictions are
632 // (N x C x H x W), the label blob is expected to contain N*H*W ground truth
633 // labels with integer values in {0, 1, ..., C-1}.
634 optional int32 axis = 2 [default = 1];
636 // If specified, ignore instances with the given label.
637 optional int32 ignore_label = 3;
640 message ArgMaxParameter {
641 // If true produce pairs (argmax, maxval)
642 optional bool out_max_val = 1 [default = false];
643 optional uint32 top_k = 2 [default = 1];
644 // The axis along which to maximise -- may be negative to index from the
645 // end (e.g., -1 for the last axis).
646 // By default ArgMaxLayer maximizes over the flattened trailing dimensions
647 // for each index of the first / num dimension.
648 optional int32 axis = 3;
651 message ConcatParameter {
652 // The axis along which to concatenate -- may be negative to index from the
653 // end (e.g., -1 for the last axis). Other axes must have the
654 // same dimension for all the bottom blobs.
655 // By default, ConcatLayer concatenates blobs along the "channels" axis (1).
656 optional int32 axis = 2 [default = 1];
658 // DEPRECATED: alias for "axis" -- does not support negative indexing.
659 optional uint32 concat_dim = 1 [default = 1];
662 message BatchNormParameter {
663 // If false, accumulate global mean/variance values via a moving average. If
664 // true, use those accumulated values instead of computing mean/variance
666 optional bool use_global_stats = 1;
667 // How much does the moving average decay each iteration?
668 optional float moving_average_fraction = 2 [default = .999];
669 // Small value to add to the variance estimate so that we don't divide by
671 optional float eps = 3 [default = 1e-5];
674 message BiasParameter {
675 // The first axis of bottom[0] (the first input Blob) along which to apply
676 // bottom[1] (the second input Blob). May be negative to index from the end
677 // (e.g., -1 for the last axis).
679 // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
680 // top[0] will have the same shape, and bottom[1] may have any of the
681 // following shapes (for the given value of axis):
682 // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
683 // (axis == 1 == -3) 3; 3x40; 3x40x60
684 // (axis == 2 == -2) 40; 40x60
685 // (axis == 3 == -1) 60
686 // Furthermore, bottom[1] may have the empty shape (regardless of the value of
687 // "axis") -- a scalar bias.
688 optional int32 axis = 1 [default = 1];
690 // (num_axes is ignored unless just one bottom is given and the bias is
691 // a learned parameter of the layer. Otherwise, num_axes is determined by the
692 // number of axes by the second bottom.)
693 // The number of axes of the input (bottom[0]) covered by the bias
694 // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
695 // Set num_axes := 0, to add a zero-axis Blob: a scalar.
696 optional int32 num_axes = 2 [default = 1];
698 // (filler is ignored unless just one bottom is given and the bias is
699 // a learned parameter of the layer.)
700 // The initialization for the learned bias parameter.
701 // Default is the zero (0) initialization, resulting in the BiasLayer
702 // initially performing the identity operation.
703 optional FillerParameter filler = 3;
706 message ContrastiveLossParameter {
707 // margin for dissimilar pair
708 optional float margin = 1 [default = 1.0];
709 // The first implementation of this cost did not exactly match the cost of
710 // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2.
711 // legacy_version = false (the default) uses (margin - d)^2 as proposed in the
712 // Hadsell paper. New models should probably use this version.
713 // legacy_version = true uses (margin - d^2). This is kept to support /
714 // reproduce existing models and results
715 optional bool legacy_version = 2 [default = false];
718 message ConvolutionParameter {
719 optional uint32 num_output = 1; // The number of outputs for the layer
720 optional bool bias_term = 2 [default = true]; // whether to have bias terms
722 // Pad, kernel size, and stride are all given as a single value for equal
723 // dimensions in all spatial dimensions, or once per spatial dimension.
724 repeated uint32 pad = 3; // The padding size; defaults to 0
725 repeated uint32 kernel_size = 4; // The kernel size
726 repeated uint32 stride = 6; // The stride; defaults to 1
727 // Factor used to dilate the kernel, (implicitly) zero-filling the resulting
728 // holes. (Kernel dilation is sometimes referred to by its use in the
729 // algorithme à trous from Holschneider et al. 1987.)
730 repeated uint32 dilation = 18; // The dilation; defaults to 1
732 // For 2D convolution only, the *_h and *_w versions may also be used to
733 // specify both spatial dimensions.
734 optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only)
735 optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only)
736 optional uint32 kernel_h = 11; // The kernel height (2D only)
737 optional uint32 kernel_w = 12; // The kernel width (2D only)
738 optional uint32 stride_h = 13; // The stride height (2D only)
739 optional uint32 stride_w = 14; // The stride width (2D only)
741 optional uint32 group = 5 [default = 1]; // The group size for group conv
743 optional FillerParameter weight_filler = 7; // The filler for the weight
744 optional FillerParameter bias_filler = 8; // The filler for the bias
750 optional Engine engine = 15 [default = DEFAULT];
752 // The axis to interpret as "channels" when performing convolution.
753 // Preceding dimensions are treated as independent inputs;
754 // succeeding dimensions are treated as "spatial".
755 // With (N, C, H, W) inputs, and axis == 1 (the default), we perform
756 // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for
757 // groups g>1) filters across the spatial axes (H, W) of the input.
758 // With (N, C, D, H, W) inputs, and axis == 1, we perform
759 // N independent 3D convolutions, sliding (C/g)-channels
760 // filters across the spatial axes (D, H, W) of the input.
761 optional int32 axis = 16 [default = 1];
763 // Whether to force use of the general ND convolution, even if a specific
764 // implementation for blobs of the appropriate number of spatial dimensions
765 // is available. (Currently, there is only a 2D-specific convolution
766 // implementation; for input blobs with num_axes != 2, this option is
767 // ignored and the ND implementation will be used.)
768 optional bool force_nd_im2col = 17 [default = false];
771 message CropParameter {
772 // To crop, elements of the first bottom are selected to fit the dimensions
773 // of the second, reference bottom. The crop is configured by
774 // - the crop `axis` to pick the dimensions for cropping
775 // - the crop `offset` to set the shift for all/each dimension
776 // to align the cropped bottom with the reference bottom.
777 // All dimensions up to but excluding `axis` are preserved, while
778 // the dimensions including and trailing `axis` are cropped.
779 // If only one `offset` is set, then all dimensions are offset by this amount.
780 // Otherwise, the number of offsets must equal the number of cropped axes to
781 // shift the crop in each dimension accordingly.
782 // Note: standard dimensions are N,C,H,W so the default is a spatial crop,
783 // and `axis` may be negative to index from the end (e.g., -1 for the last
785 optional int32 axis = 1 [default = 2];
786 repeated uint32 offset = 2;
789 message DataParameter {
794 // Specify the data source.
795 optional string source = 1;
796 // Specify the batch size.
797 optional uint32 batch_size = 4;
798 // The rand_skip variable is for the data layer to skip a few data points
799 // to avoid all asynchronous sgd clients to start at the same point. The skip
800 // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
801 // be larger than the number of keys in the database.
802 // DEPRECATED. Each solver accesses a different subset of the database.
803 optional uint32 rand_skip = 7 [default = 0];
804 optional DB backend = 8 [default = LEVELDB];
805 // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
806 // simple scaling and subtracting the data mean, if provided. Note that the
807 // mean subtraction is always carried out before scaling.
808 optional float scale = 2 [default = 1];
809 optional string mean_file = 3;
810 // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
812 optional uint32 crop_size = 5 [default = 0];
813 // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
815 optional bool mirror = 6 [default = false];
816 // Force the encoded image to have 3 color channels
817 optional bool force_encoded_color = 9 [default = false];
818 // Prefetch queue (Number of batches to prefetch to host memory, increase if
819 // data access bandwidth varies).
820 optional uint32 prefetch = 10 [default = 4];
823 message NonMaximumSuppressionParameter {
824 // Threshold to be used in nms.
825 optional float nms_threshold = 1 [default = 0.3];
826 // Maximum number of results to be kept.
827 optional int32 top_k = 2;
828 // Parameter for adaptive nms.
829 optional float eta = 3 [default = 1.0];
832 message SaveOutputParameter {
833 // Output directory. If not empty, we will save the results.
834 optional string output_directory = 1;
835 // Output name prefix.
836 optional string output_name_prefix = 2;
838 // VOC - PASCAL VOC output format.
839 // COCO - MS COCO output format.
840 optional string output_format = 3;
841 // If you want to output results, must also provide the following two files.
842 // Otherwise, we will ignore saving results.
844 optional string label_map_file = 4;
845 // A file which contains a list of names and sizes with same order
846 // of the input DB. The file is in the following format:
849 optional string name_size_file = 5;
850 // Number of test images. It can be less than the lines specified in
851 // name_size_file. For example, when we only want to evaluate on part
852 // of the test images.
853 optional uint32 num_test_image = 6;
856 message DropoutParameter {
857 optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio
858 // Faster-RCNN framework's parameter.
859 // source: https://github.com/rbgirshick/caffe-fast-rcnn/tree/faster-rcnn
860 optional bool scale_train = 2 [default = true]; // scale train or test phase
863 // DummyDataLayer fills any number of arbitrarily shaped blobs with random
864 // (or constant) data generated by "Fillers" (see "message FillerParameter").
865 message DummyDataParameter {
866 // This layer produces N >= 1 top blobs. DummyDataParameter must specify 1 or N
867 // shape fields, and 0, 1 or N data_fillers.
869 // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used.
870 // If 1 data_filler is specified, it is applied to all top blobs. If N are
871 // specified, the ith is applied to the ith top blob.
872 repeated FillerParameter data_filler = 1;
873 repeated BlobShape shape = 6;
875 // 4D dimensions -- deprecated. Use "shape" instead.
876 repeated uint32 num = 2;
877 repeated uint32 channels = 3;
878 repeated uint32 height = 4;
879 repeated uint32 width = 5;
882 message EltwiseParameter {
888 optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation
889 repeated float coeff = 2; // blob-wise coefficient for SUM operation
891 // Whether to use an asymptotically slower (for >2 inputs) but stabler method
892 // of computing the gradient for the PROD operation. (No effect for SUM op.)
893 optional bool stable_prod_grad = 3 [default = true];
896 // Message that stores parameters used by ELULayer
897 message ELUParameter {
899 // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate
900 // Deep Network Learning by Exponential Linear Units (ELUs). arXiv
901 optional float alpha = 1 [default = 1];
904 // Message that stores parameters used by EmbedLayer
905 message EmbedParameter {
906 optional uint32 num_output = 1; // The number of outputs for the layer
907 // The input is given as integers to be interpreted as one-hot
908 // vector indices with dimension num_input. Hence num_input should be
909 // 1 greater than the maximum possible input value.
910 optional uint32 input_dim = 2;
912 optional bool bias_term = 3 [default = true]; // Whether to use a bias term
913 optional FillerParameter weight_filler = 4; // The filler for the weight
914 optional FillerParameter bias_filler = 5; // The filler for the bias
918 // Message that stores parameters used by ExpLayer
919 message ExpParameter {
920 // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0.
921 // Or if base is set to the default (-1), base is set to e,
922 // so y = exp(shift + scale * x).
923 optional float base = 1 [default = -1.0];
924 optional float scale = 2 [default = 1.0];
925 optional float shift = 3 [default = 0.0];
928 /// Message that stores parameters used by FlattenLayer
929 message FlattenParameter {
930 // The first axis to flatten: all preceding axes are retained in the output.
931 // May be negative to index from the end (e.g., -1 for the last axis).
932 optional int32 axis = 1 [default = 1];
934 // The last axis to flatten: all following axes are retained in the output.
935 // May be negative to index from the end (e.g., the default -1 for the last
937 optional int32 end_axis = 2 [default = -1];
940 // Message that stores parameters used by HDF5DataLayer
941 message HDF5DataParameter {
942 // Specify the data source.
943 optional string source = 1;
944 // Specify the batch size.
945 optional uint32 batch_size = 2;
947 // Specify whether to shuffle the data.
948 // If shuffle == true, the ordering of the HDF5 files is shuffled,
949 // and the ordering of data within any given HDF5 file is shuffled,
950 // but data between different files are not interleaved; all of a file's
951 // data are output (in a random order) before moving onto another file.
952 optional bool shuffle = 3 [default = false];
955 message HDF5OutputParameter {
956 optional string file_name = 1;
959 message HingeLossParameter {
964 // Specify the Norm to use L1 or L2
965 optional Norm norm = 1 [default = L1];
968 message ImageDataParameter {
969 // Specify the data source.
970 optional string source = 1;
971 // Specify the batch size.
972 optional uint32 batch_size = 4 [default = 1];
973 // The rand_skip variable is for the data layer to skip a few data points
974 // to avoid all asynchronous sgd clients to start at the same point. The skip
975 // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
976 // be larger than the number of keys in the database.
977 optional uint32 rand_skip = 7 [default = 0];
978 // Whether or not ImageLayer should shuffle the list of files at every epoch.
979 optional bool shuffle = 8 [default = false];
980 // It will also resize images if new_height or new_width are not zero.
981 optional uint32 new_height = 9 [default = 0];
982 optional uint32 new_width = 10 [default = 0];
983 // Specify if the images are color or gray
984 optional bool is_color = 11 [default = true];
985 // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
986 // simple scaling and subtracting the data mean, if provided. Note that the
987 // mean subtraction is always carried out before scaling.
988 optional float scale = 2 [default = 1];
989 optional string mean_file = 3;
990 // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
992 optional uint32 crop_size = 5 [default = 0];
993 // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
995 optional bool mirror = 6 [default = false];
996 optional string root_folder = 12 [default = ""];
999 message InfogainLossParameter {
1000 // Specify the infogain matrix source.
1001 optional string source = 1;
1004 message InnerProductParameter {
1005 optional uint32 num_output = 1; // The number of outputs for the layer
1006 optional bool bias_term = 2 [default = true]; // whether to have bias terms
1007 optional FillerParameter weight_filler = 3; // The filler for the weight
1008 optional FillerParameter bias_filler = 4; // The filler for the bias
1010 // The first axis to be lumped into a single inner product computation;
1011 // all preceding axes are retained in the output.
1012 // May be negative to index from the end (e.g., -1 for the last axis).
1013 optional int32 axis = 5 [default = 1];
1014 // Specify whether to transpose the weight matrix or not.
1015 // If transpose == true, any operations will be performed on the transpose
1016 // of the weight matrix. The weight matrix itself is not going to be transposed
1017 // but rather the transfer flag of operations will be toggled accordingly.
1018 optional bool transpose = 6 [default = false];
1021 message InputParameter {
1022 // This layer produces N >= 1 top blob(s) to be assigned manually.
1023 // Define N shapes to set a shape for each top.
1024 // Define 1 shape to set the same shape for every top.
1025 // Define no shape to defer to reshaping manually.
1026 repeated BlobShape shape = 1;
1029 // Message that stores parameters used by LogLayer
1030 message LogParameter {
1031 // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0.
1032 // Or if base is set to the default (-1), base is set to e,
1033 // so y = ln(shift + scale * x) = log_e(shift + scale * x)
1034 optional float base = 1 [default = -1.0];
1035 optional float scale = 2 [default = 1.0];
1036 optional float shift = 3 [default = 0.0];
1039 // Message that stores parameters used by LRNLayer
1040 message LRNParameter {
1041 optional uint32 local_size = 1 [default = 5];
1042 optional float alpha = 2 [default = 1.];
1043 optional float beta = 3 [default = 0.75];
1045 ACROSS_CHANNELS = 0;
1048 optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
1049 optional float k = 5 [default = 1.];
1055 optional Engine engine = 6 [default = DEFAULT];
1058 message MemoryDataParameter {
1059 optional uint32 batch_size = 1;
1060 optional uint32 channels = 2;
1061 optional uint32 height = 3;
1062 optional uint32 width = 4;
1065 message MVNParameter {
1066 // This parameter can be set to false to normalize mean only
1067 optional bool normalize_variance = 1 [default = true];
1069 // This parameter can be set to true to perform DNN-like MVN
1070 optional bool across_channels = 2 [default = false];
1072 // Epsilon for not dividing by zero while normalizing variance
1073 optional float eps = 3 [default = 1e-9];
1076 message ParameterParameter {
1077 optional BlobShape shape = 1;
1080 message PoolingParameter {
1086 optional PoolMethod pool = 1 [default = MAX]; // The pooling method
1087 // Pad, kernel size, and stride are all given as a single value for equal
1088 // dimensions in height and width or as Y, X pairs.
1089 optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X)
1090 optional uint32 pad_h = 9 [default = 0]; // The padding height
1091 optional uint32 pad_w = 10 [default = 0]; // The padding width
1092 optional uint32 kernel_size = 2; // The kernel size (square)
1093 optional uint32 kernel_h = 5; // The kernel height
1094 optional uint32 kernel_w = 6; // The kernel width
1095 optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X)
1096 optional uint32 stride_h = 7; // The stride height
1097 optional uint32 stride_w = 8; // The stride width
1103 optional Engine engine = 11 [default = DEFAULT];
1104 // If global_pooling then it will pool over the size of the bottom by doing
1105 // kernel_h = bottom->height and kernel_w = bottom->width
1106 optional bool global_pooling = 12 [default = false];
1107 // Specify floor/ceil mode
1108 // source: https://github.com/BVLC/caffe/pull/3057
1109 optional bool ceil_mode = 13 [default = true];
1112 message PowerParameter {
1113 // PowerLayer computes outputs y = (shift + scale * x) ^ power.
1114 optional float power = 1 [default = 1.0];
1115 optional float scale = 2 [default = 1.0];
1116 optional float shift = 3 [default = 0.0];
1119 message PythonParameter {
1120 optional string module = 1;
1121 optional string layer = 2;
1122 // This value is set to the attribute `param_str` of the `PythonLayer` object
1123 // in Python before calling the `setup()` method. This could be a number,
1124 // string, dictionary in Python dict format, JSON, etc. You may parse this
1125 // string in `setup` method and use it in `forward` and `backward`.
1126 optional string param_str = 3 [default = ''];
1127 // Whether this PythonLayer is shared among worker solvers during data parallelism.
1128 // If true, each worker solver sequentially run forward from this layer.
1129 // This value should be set true if you are using it as a data layer.
1130 optional bool share_in_parallel = 4 [default = false];
1133 // Message that stores parameters used by RecurrentLayer
1134 message RecurrentParameter {
1135 // The dimension of the output (and usually hidden state) representation --
1136 // must be explicitly set to non-zero.
1137 optional uint32 num_output = 1 [default = 0];
1139 optional FillerParameter weight_filler = 2; // The filler for the weight
1140 optional FillerParameter bias_filler = 3; // The filler for the bias
1142 // Whether to enable displaying debug_info in the unrolled recurrent net.
1143 optional bool debug_info = 4 [default = false];
1145 // Whether to add as additional inputs (bottoms) the initial hidden state
1146 // blobs, and add as additional outputs (tops) the final timestep hidden state
1147 // blobs. The number of additional bottom/top blobs required depends on the
1148 // recurrent architecture -- e.g., 1 for RNNs, 2 for LSTMs.
1149 optional bool expose_hidden = 5 [default = false];
1152 // Message that stores parameters used by ReductionLayer
1153 message ReductionParameter {
1161 optional ReductionOp operation = 1 [default = SUM]; // reduction operation
1163 // The first axis to reduce to a scalar -- may be negative to index from the
1164 // end (e.g., -1 for the last axis).
1165 // (Currently, only reduction along ALL "tail" axes is supported; reduction
1166 // of axis M through N, where N < num_axes - 1, is unsupported.)
1167 // Suppose we have an n-axis bottom Blob with shape:
1168 // (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)).
1169 // If axis == m, the output Blob will have shape
1170 // (d0, d1, d2, ..., d(m-1)),
1171 // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1))
1172 // times, each including (dm * d(m+1) * ... * d(n-1)) individual data.
1173 // If axis == 0 (the default), the output Blob always has the empty shape
1174 // (count 1), performing reduction across the entire input --
1175 // often useful for creating new loss functions.
1176 optional int32 axis = 2 [default = 0];
1178 optional float coeff = 3 [default = 1.0]; // coefficient for output
1181 // Message that stores parameters used by ReLULayer
1182 message ReLUParameter {
1183 // Allow non-zero slope for negative inputs to speed up optimization
1185 // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities
1186 // improve neural network acoustic models. In ICML Workshop on Deep Learning
1187 // for Audio, Speech, and Language Processing.
1188 optional float negative_slope = 1 [default = 0];
1194 optional Engine engine = 2 [default = DEFAULT];
1197 message ReshapeParameter {
1198 // Specify the output dimensions. If some of the dimensions are set to 0,
1199 // the corresponding dimension from the bottom layer is used (unchanged).
1200 // Exactly one dimension may be set to -1, in which case its value is
1201 // inferred from the count of the bottom blob and the remaining dimensions.
1202 // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8:
1205 // type: "Reshape" bottom: "input" top: "output"
1206 // reshape_param { ... }
1209 // If "input" is 2D with shape 2 x 8, then the following reshape_param
1210 // specifications are all equivalent, producing a 3D blob "output" with shape
1213 // reshape_param { shape { dim: 2 dim: 2 dim: 4 } }
1214 // reshape_param { shape { dim: 0 dim: 2 dim: 4 } }
1215 // reshape_param { shape { dim: 0 dim: 2 dim: -1 } }
1216 // reshape_param { shape { dim: 0 dim:-1 dim: 4 } }
1218 optional BlobShape shape = 1;
1220 // axis and num_axes control the portion of the bottom blob's shape that are
1221 // replaced by (included in) the reshape. By default (axis == 0 and
1222 // num_axes == -1), the entire bottom blob shape is included in the reshape,
1223 // and hence the shape field must specify the entire output shape.
1225 // axis may be non-zero to retain some portion of the beginning of the input
1226 // shape (and may be negative to index from the end; e.g., -1 to begin the
1227 // reshape after the last axis, including nothing in the reshape,
1228 // -2 to include only the last axis, etc.).
1230 // For example, suppose "input" is a 2D blob with shape 2 x 8.
1231 // Then the following ReshapeLayer specifications are all equivalent,
1232 // producing a blob "output" with shape 2 x 2 x 4:
1234 // reshape_param { shape { dim: 2 dim: 2 dim: 4 } }
1235 // reshape_param { shape { dim: 2 dim: 4 } axis: 1 }
1236 // reshape_param { shape { dim: 2 dim: 4 } axis: -3 }
1238 // num_axes specifies the extent of the reshape.
1239 // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on
1240 // input axes in the range [axis, axis+num_axes].
1241 // num_axes may also be -1, the default, to include all remaining axes
1242 // (starting from axis).
1244 // For example, suppose "input" is a 2D blob with shape 2 x 8.
1245 // Then the following ReshapeLayer specifications are equivalent,
1246 // producing a blob "output" with shape 1 x 2 x 8.
1248 // reshape_param { shape { dim: 1 dim: 2 dim: 8 } }
1249 // reshape_param { shape { dim: 1 dim: 2 } num_axes: 1 }
1250 // reshape_param { shape { dim: 1 } num_axes: 0 }
1252 // On the other hand, these would produce output blob shape 2 x 1 x 8:
1254 // reshape_param { shape { dim: 2 dim: 1 dim: 8 } }
1255 // reshape_param { shape { dim: 1 } axis: 1 num_axes: 0 }
1257 optional int32 axis = 2 [default = 0];
1258 optional int32 num_axes = 3 [default = -1];
1261 message ScaleParameter {
1262 // The first axis of bottom[0] (the first input Blob) along which to apply
1263 // bottom[1] (the second input Blob). May be negative to index from the end
1264 // (e.g., -1 for the last axis).
1266 // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
1267 // top[0] will have the same shape, and bottom[1] may have any of the
1268 // following shapes (for the given value of axis):
1269 // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
1270 // (axis == 1 == -3) 3; 3x40; 3x40x60
1271 // (axis == 2 == -2) 40; 40x60
1272 // (axis == 3 == -1) 60
1273 // Furthermore, bottom[1] may have the empty shape (regardless of the value of
1274 // "axis") -- a scalar multiplier.
1275 optional int32 axis = 1 [default = 1];
1277 // (num_axes is ignored unless just one bottom is given and the scale is
1278 // a learned parameter of the layer. Otherwise, num_axes is determined by the
1279 // number of axes by the second bottom.)
1280 // The number of axes of the input (bottom[0]) covered by the scale
1281 // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
1282 // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar.
1283 optional int32 num_axes = 2 [default = 1];
1285 // (filler is ignored unless just one bottom is given and the scale is
1286 // a learned parameter of the layer.)
1287 // The initialization for the learned scale parameter.
1288 // Default is the unit (1) initialization, resulting in the ScaleLayer
1289 // initially performing the identity operation.
1290 optional FillerParameter filler = 3;
1292 // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but
1293 // may be more efficient). Initialized with bias_filler (defaults to 0).
1294 optional bool bias_term = 4 [default = false];
1295 optional FillerParameter bias_filler = 5;
1298 message SigmoidParameter {
1304 optional Engine engine = 1 [default = DEFAULT];
1307 message SliceParameter {
1308 // The axis along which to slice -- may be negative to index from the end
1309 // (e.g., -1 for the last axis).
1310 // By default, SliceLayer concatenates blobs along the "channels" axis (1).
1311 optional int32 axis = 3 [default = 1];
1312 repeated uint32 slice_point = 2;
1314 // DEPRECATED: alias for "axis" -- does not support negative indexing.
1315 optional uint32 slice_dim = 1 [default = 1];
1318 // Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer
1319 message SoftmaxParameter {
1325 optional Engine engine = 1 [default = DEFAULT];
1327 // The axis along which to perform the softmax -- may be negative to index
1328 // from the end (e.g., -1 for the last axis).
1329 // Any other axes will be evaluated as independent softmaxes.
1330 optional int32 axis = 2 [default = 1];
1333 message TanHParameter {
1339 optional Engine engine = 1 [default = DEFAULT];
1342 // Message that stores parameters used by TileLayer
1343 message TileParameter {
1344 // The index of the axis to tile.
1345 optional int32 axis = 1 [default = 1];
1347 // The number of copies (tiles) of the blob to output.
1348 optional int32 tiles = 2;
1351 // Message that stores parameters used by ThresholdLayer
1352 message ThresholdParameter {
1353 optional float threshold = 1 [default = 0]; // Strictly positive values
1356 message WindowDataParameter {
1357 // Specify the data source.
1358 optional string source = 1;
1359 // For data pre-processing, we can do simple scaling and subtracting the
1360 // data mean, if provided. Note that the mean subtraction is always carried
1361 // out before scaling.
1362 optional float scale = 2 [default = 1];
1363 optional string mean_file = 3;
1364 // Specify the batch size.
1365 optional uint32 batch_size = 4;
1366 // Specify if we would like to randomly crop an image.
1367 optional uint32 crop_size = 5 [default = 0];
1368 // Specify if we want to randomly mirror data.
1369 optional bool mirror = 6 [default = false];
1370 // Foreground (object) overlap threshold
1371 optional float fg_threshold = 7 [default = 0.5];
1372 // Background (non-object) overlap threshold
1373 optional float bg_threshold = 8 [default = 0.5];
1374 // Fraction of batch that should be foreground objects
1375 optional float fg_fraction = 9 [default = 0.25];
1376 // Amount of contextual padding to add around a window
1377 // (used only by the window_data_layer)
1378 optional uint32 context_pad = 10 [default = 0];
1379 // Mode for cropping out a detection window
1380 // warp: cropped window is warped to a fixed size and aspect ratio
1381 // square: the tightest square around the window is cropped
1382 optional string crop_mode = 11 [default = "warp"];
1383 // cache_images: will load all images in memory for faster access
1384 optional bool cache_images = 12 [default = false];
1385 // append root_folder to locate images
1386 optional string root_folder = 13 [default = ""];
1389 message SPPParameter {
1395 optional uint32 pyramid_height = 1;
1396 optional PoolMethod pool = 2 [default = MAX]; // The pooling method
1402 optional Engine engine = 6 [default = DEFAULT];
1405 // DEPRECATED: use LayerParameter.
1406 message V1LayerParameter {
1407 repeated string bottom = 2;
1408 repeated string top = 3;
1409 optional string name = 4;
1410 repeated NetStateRule include = 32;
1411 repeated NetStateRule exclude = 33;
1419 CONTRASTIVE_LOSS = 37;
1438 MULTINOMIAL_LOGISTIC_LOSS = 16;
1444 SIGMOID_CROSS_ENTROPY_LOSS = 27;
1454 optional LayerType type = 5;
1455 repeated BlobProto blobs = 6;
1456 repeated string param = 1001;
1457 repeated DimCheckMode blob_share_mode = 1002;
1462 repeated float blobs_lr = 7;
1463 repeated float weight_decay = 8;
1464 repeated float loss_weight = 35;
1465 optional AccuracyParameter accuracy_param = 27;
1466 optional ArgMaxParameter argmax_param = 23;
1467 optional ConcatParameter concat_param = 9;
1468 optional ContrastiveLossParameter contrastive_loss_param = 40;
1469 optional ConvolutionParameter convolution_param = 10;
1470 optional DataParameter data_param = 11;
1471 optional DropoutParameter dropout_param = 12;
1472 optional DummyDataParameter dummy_data_param = 26;
1473 optional EltwiseParameter eltwise_param = 24;
1474 optional ExpParameter exp_param = 41;
1475 optional HDF5DataParameter hdf5_data_param = 13;
1476 optional HDF5OutputParameter hdf5_output_param = 14;
1477 optional HingeLossParameter hinge_loss_param = 29;
1478 optional ImageDataParameter image_data_param = 15;
1479 optional InfogainLossParameter infogain_loss_param = 16;
1480 optional InnerProductParameter inner_product_param = 17;
1481 optional LRNParameter lrn_param = 18;
1482 optional MemoryDataParameter memory_data_param = 22;
1483 optional MVNParameter mvn_param = 34;
1484 optional PoolingParameter pooling_param = 19;
1485 optional PowerParameter power_param = 21;
1486 optional ReLUParameter relu_param = 30;
1487 optional SigmoidParameter sigmoid_param = 38;
1488 optional SoftmaxParameter softmax_param = 39;
1489 optional SliceParameter slice_param = 31;
1490 optional TanHParameter tanh_param = 37;
1491 optional ThresholdParameter threshold_param = 25;
1492 optional WindowDataParameter window_data_param = 20;
1493 optional TransformationParameter transform_param = 36;
1494 optional LossParameter loss_param = 42;
1495 optional V0LayerParameter layer = 1;
1498 // DEPRECATED: V0LayerParameter is the old way of specifying layer parameters
1499 // in Caffe. We keep this message type around for legacy support.
1500 message V0LayerParameter {
1501 optional string name = 1; // the layer name
1502 optional string type = 2; // the string to specify the layer type
1504 // Parameters to specify layers with inner products.
1505 optional uint32 num_output = 3; // The number of outputs for the layer
1506 optional bool biasterm = 4 [default = true]; // whether to have bias terms
1507 optional FillerParameter weight_filler = 5; // The filler for the weight
1508 optional FillerParameter bias_filler = 6; // The filler for the bias
1510 optional uint32 pad = 7 [default = 0]; // The padding size
1511 optional uint32 kernelsize = 8; // The kernel size
1512 optional uint32 group = 9 [default = 1]; // The group size for group conv
1513 optional uint32 stride = 10 [default = 1]; // The stride
1519 optional PoolMethod pool = 11 [default = MAX]; // The pooling method
1520 optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio
1522 optional uint32 local_size = 13 [default = 5]; // for local response norm
1523 optional float alpha = 14 [default = 1.]; // for local response norm
1524 optional float beta = 15 [default = 0.75]; // for local response norm
1525 optional float k = 22 [default = 1.];
1527 // For data layers, specify the data source
1528 optional string source = 16;
1529 // For data pre-processing, we can do simple scaling and subtracting the
1530 // data mean, if provided. Note that the mean subtraction is always carried
1531 // out before scaling.
1532 optional float scale = 17 [default = 1];
1533 optional string meanfile = 18;
1534 // For data layers, specify the batch size.
1535 optional uint32 batchsize = 19;
1536 // For data layers, specify if we would like to randomly crop an image.
1537 optional uint32 cropsize = 20 [default = 0];
1538 // For data layers, specify if we want to randomly mirror data.
1539 optional bool mirror = 21 [default = false];
1541 // The blobs containing the numeric parameters of the layer
1542 repeated BlobProto blobs = 50;
1543 // The ratio that is multiplied on the global learning rate. If you want to
1544 // set the learning ratio for one blob, you need to set it for all blobs.
1545 repeated float blobs_lr = 51;
1546 // The weight decay that is multiplied on the global weight decay.
1547 repeated float weight_decay = 52;
1549 // The rand_skip variable is for the data layer to skip a few data points
1550 // to avoid all asynchronous sgd clients to start at the same point. The skip
1551 // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
1552 // be larger than the number of keys in the database.
1553 optional uint32 rand_skip = 53 [default = 0];
1555 // Fields related to detection (det_*)
1556 // foreground (object) overlap threshold
1557 optional float det_fg_threshold = 54 [default = 0.5];
1558 // background (non-object) overlap threshold
1559 optional float det_bg_threshold = 55 [default = 0.5];
1560 // Fraction of batch that should be foreground objects
1561 optional float det_fg_fraction = 56 [default = 0.25];
1563 // optional bool OBSOLETE_can_clobber = 57 [default = true];
1565 // Amount of contextual padding to add around a window
1566 // (used only by the window_data_layer)
1567 optional uint32 det_context_pad = 58 [default = 0];
1569 // Mode for cropping out a detection window
1570 // warp: cropped window is warped to a fixed size and aspect ratio
1571 // square: the tightest square around the window is cropped
1572 optional string det_crop_mode = 59 [default = "warp"];
1574 // For ReshapeLayer, one needs to specify the new dimensions.
1575 optional int32 new_num = 60 [default = 0];
1576 optional int32 new_channels = 61 [default = 0];
1577 optional int32 new_height = 62 [default = 0];
1578 optional int32 new_width = 63 [default = 0];
1580 // Whether or not ImageLayer should shuffle the list of files at every epoch.
1581 // It will also resize images if new_height or new_width are not zero.
1582 optional bool shuffle_images = 64 [default = false];
1584 // For ConcatLayer, one needs to specify the dimension for concatenation, and
1585 // the other dimensions must be the same for all the bottom blobs.
1586 // By default it will concatenate blobs along the channels dimension.
1587 optional uint32 concat_dim = 65 [default = 1];
1589 optional HDF5OutputParameter hdf5_output_param = 1001;
1592 message PReLUParameter {
1593 // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers:
1594 // Surpassing Human-Level Performance on ImageNet Classification, 2015.
1596 // Initial value of a_i. Default is a_i=0.25 for all i.
1597 optional FillerParameter filler = 1;
1598 // Whether or not slope parameters are shared across channels.
1599 optional bool channel_shared = 2 [default = false];
1602 // The normalized bounding box [0, 1] w.r.t. the input image size.
1603 message NormalizedBBox {
1604 optional float xmin = 1;
1605 optional float ymin = 2;
1606 optional float xmax = 3;
1607 optional float ymax = 4;
1608 optional int32 label = 5;
1609 optional bool difficult = 6;
1610 optional float score = 7;
1611 optional float size = 8;
1614 // origin: https://github.com/rbgirshick/caffe-fast-rcnn/tree/fast-rcnn
1615 // Message that stores parameters used by ROIPoolingLayer
1616 message ROIPoolingParameter {
1617 // Pad, kernel size, and stride are all given as a single value for equal
1618 // dimensions in height and width or as Y, X pairs.
1619 optional uint32 pooled_h = 1 [default = 0]; // The pooled output height
1620 optional uint32 pooled_w = 2 [default = 0]; // The pooled output width
1621 // Multiplicative spatial scale factor to translate ROI coords from their
1622 // input scale to the scale used when pooling
1623 optional float spatial_scale = 3 [default = 1];
1626 message ProposalParameter {
1627 optional uint32 feat_stride = 1 [default = 16];
1628 optional uint32 base_size = 2 [default = 16];
1629 optional uint32 min_size = 3 [default = 16];
1630 repeated float ratio = 4;
1631 repeated float scale = 5;
1632 optional uint32 pre_nms_topn = 6 [default = 6000];
1633 optional uint32 post_nms_topn = 7 [default = 300];
1634 optional float nms_thresh = 8 [default = 0.7];