caffe的caffe.proto

来源:互联网 发布:金蝶网络破解版 编辑:程序博客网 时间:2024/05/16 19:19
经过前面“caffe的protocol buffer使用例子”的学习,对caffe.proto熟悉了。
看caffe源码先从这里开始吧。
它位于…\src\caffe\proto目录下,在这个文件夹下还有一个.pb.cc和一个.pb.h文件,这两个文件都是由caffe.proto编译而来的。
在caffe.proto中定义了很多结构化数据,包括:
  • BlobProto
  • Datum
  • FillerParameter
  • NetParameter
  • SolverParameter
  • SolverState
  • LayerParameter
  • ConcatParameter
  • ConvolutionParameter
  • DataParameter
  • DropoutParameter
  • HDF5DataParameter
  • HDF5OutputParameter
  • ImageDataParameter
  • InfogainLossParameter
  • InnerProductParameter
  • LRNParameter
  • MemoryDataParameter
  • PoolingParameter
  • PowerParameter
  • WindowDataParameter
  • V0LayerParameter
从caffe.proto编译而来的,无非就是一些关于这些数据结构(类)的标准化操作,比如:
  void CopyFrom();//在ByteString中定义实现ByteString和字节数组/字符串互相转换函数
  void MergeFrom();//用于合并
  void Clear();
  bool IsInitialized() const;
  int ByteSize() const;

  bool MergePartialFromCodedStream();//解码时可以调用C++接口ParseFromArray,编码时可以先调用C++接口ByteSize预先获得编码后的数据大小,让后动态分配内存后调用SerializeToArray进行编码即可。

  void SerializeWithCachedSizes() const;//序列化打包
  SerializeWithCachedSizesToArray() const;
  int GetCachedSize()//打包后出来的大小
  void SharedCtor();
  void SharedDtor();
  void SetCachedSize() const;
这一注释部分是来自人工智能研究网。
[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
  1. //////////////////  
  2. caffe.proto文件注释,  
  3. caffe版本:MS-caffe-master github 2016.8.20  
  4. caffe版本:BVLC-caffe-master github 2016.8.20  
  5. //////////////////  
  6. syntax = "proto2";  
  7. package caffe;    
  8. // 数据块形状{指定Blob的形状或维度-4D}  
  9. message BlobShape {  
  10.   //数据块形状定义为Num×Channel×Height×Wight原因在于caffe基于容器的多维嵌套  
  11.   //来实现高维数据的封装。即vector(N)>。  
  12.   repeated int64 dim = 1 [packed = true];  
  13. }  
  14.   
  15. // 数据块{形状,数据,微分}  
  16. message BlobProto {  
  17.   optional BlobShape shape = 7;  
  18.   repeated float data = 5 [packed = true];  
  19.   repeated float diff = 6 [packed = true];  
  20.   repeated double double_data = 8 [packed = true];  
  21.   repeated double double_diff = 9 [packed = true];  
  22.   
  23.   //数据4D形状 -- 旧版本,已使用"BlobShape shape"代替:  
  24.   optional int32 num = 1 [default = 0]; //样本  
  25.   optional int32 channels = 2 [default = 0];  
  26.   optional int32 height = 3 [default = 0];  
  27.   optional int32 width = 4 [default = 0];  
  28. }  
  29.   
  30. // 存放多个BlobProto实例的对应Index,易于引用  
  31. message BlobProtoVector {  
  32.   repeated BlobProto blobs = 1;  
  33. }  
  34.   
  35. // 数据:{C,H,W,data(uchar&float),label} 图像样本  
  36. message Datum {  
  37.   optional int32 channels = 1;  
  38.   optional int32 height = 2;  
  39.   optional int32 width = 3;  
  40.   // the actual image data, in bytes  
  41.   optional bytes data = 4;  
  42.   optional int32 label = 5;  
  43.   // Optionally, the datum could also hold float data.  
  44.   repeated float float_data = 6;  
  45.   // If true data contains an encoded image that need to be decoded  
  46.   optional bool encoded = 7 [default = false];  
  47. }  
  48.   
  49. //滤波器参数{Type(const|uniform|gauss),}  
  50. message FillerParameter {  
  51.   // The filler type.  
  52.   optional string type = 1 [default = 'constant'];  
  53.   optional float value = 2 [default = 0]; // the value in constant filler  
  54.   optional float min = 3 [default = 0]; // the min value in uniform filler  
  55.   optional float max = 4 [default = 1]; // the max value in uniform filler  
  56.   optional float mean = 5 [default = 0]; // the mean value in Gaussian filler  
  57.   optional float std = 6 [default = 1]; // the std value in Gaussian filler  
  58.   // 给定输入与权值相乘后应该得到非零输出,默认值-1意为不稀疏化高斯模板。  
  59.   optional int32 sparse = 7 [default = -1];  
  60.   // Normalize the filler variance by fan_in, fan_out, or their average.  
  61.   // Applies to 'xavier' and 'msra' fillers.(扇入,扇出)  
  62.   // 通过fanIn,fanOut,及其均值来归一化填充值的方差,有“xavier法”或“msra法”  
  63.   enum VarianceNorm {  
  64.     FAN_IN = 0;  
  65.     FAN_OUT = 1;  
  66.     AVERAGE = 2;  
  67.   }  
  68.   optional VarianceNorm variance_norm = 8 [default = FAN_IN];  
  69. }  
  70.   
  71. //网络参数{网名,输入参数,数据块形状,forceBack,NetState,debugInfo,}  
  72. message NetParameter {  
  73.   optional string name = 1; // consider giving the network a name  
  74.   // 旧版--输入网络的数据块Blobs; 改为新版--InputParameter  
  75.   repeated string input = 3;  
  76.   // DEPRECATED. See InputParameter. The shape of the input blobs.  
  77.   // 旧版--输入的Blobs的形状; 改为新版--InputerParameter  
  78.   repeated BlobShape input_shape = 8;  
  79.   
  80.   // 指定Blobs的4D输入形状 -- 已改为新版:input_shape代替  
  81.   // 如要使用旧版,对每个输入的blob都需要指定4个参数,Num×Cha×H×W  
  82.   // 因此 input_dim需要重复4次  
  83.   repeated int32 input_dim = 4;  
  84.   
  85.   //确定网络是否要让每个层都强制反向传播。  
  86.   //如果设置为false,将根据网络结构和学习率来自动确定是否需要反向传播。  
  87.   //网络的当前状态"state"包括"phase","level","stage"。(???)  
  88.   //某些层需要设置phase属性,使其跳过网络运行时的某些状态.  
  89.   optional NetState state = 6;  
  90.   
  91.   // 当运行Net::Forward/Backward/Update时,打印调试信息,默认false.  
  92.   optional bool debug_info = 7 [default = false];  
  93.   
  94.   // 构成net的layers。每个layer的链接和行为通过LayerParameter配置。  
  95.   repeated LayerParameter layer = 100;  // ID 100 so layers are printed last.  
  96.   
  97.   // DEPRECATED: use 'layer' instead.  
  98.   repeated V1LayerParameter layers = 2;  
  99. }  
  100.   
  101. // NOTE:注意  
  102. // Update the next available ID when you add a new SolverParameter field.  
  103. // 当你添加一个新的SolverParameter属性时,需要更新下一个可获得的ID  
  104. // SolverParameter next available ID: 41 (last added: type)  
  105.   
  106. //求解器参数{网络,}  
  107. message SolverParameter {  
  108.   //////////////////////////////////////////////////////////////////////////////  
  109.   // Specifying the train and test networks  
  110.   //  
  111.   // Exactly one train net must be specified using one of the following fields:  
  112.   //     train_net_param, train_net, net_param, net  
  113.   // One or more test nets may be specified using any of the following fields:  
  114.   //     test_net_param, test_net, net_param, net  
  115.   // If more than one test net field is specified (e.g., both net and  
  116.   // test_net are specified), they will be evaluated in the field order given  
  117.   // above: (1) test_net_param, (2) test_net, (3) net_param/net.  
  118.   // A test_iter must be specified for each test_net.  
  119.   // A test_level and/or a test_stage may also be specified for each test_net.  
  120.   //////////////////////////////////////////////////////////////////////////////  
  121.   //指定网络,可有以下的多种形式  
  122.   // Proto filename for the train net, possibly combined with one or more  
  123.   // test nets.  
  124.   optional string net = 24;  
  125.   // Inline train net param, possibly combined with one or more test nets.  
  126.   optional NetParameter net_param = 25;  
  127.   
  128.   optional string train_net = 1; // Proto filename for the train net.  
  129.   repeated string test_net = 2; // Proto filenames for the test nets.  
  130.   optional NetParameter train_net_param = 21; // Inline train net params.  
  131.   repeated NetParameter test_net_param = 22; // Inline test net params.  
  132.   
  133.  // 指定网络状态  
  134.  // The states for the train/test nets. Must be unspecified or  
  135.   // specified once per net.  
  136.   //  
  137.   // By default, all states will have solver = true;  
  138.   // train_state will have phase = TRAIN,  
  139.   // and all test_state's will have phase = TEST.  
  140.   // Other defaults are set according to the NetState defaults.  
  141.   optional NetState train_state = 26;  
  142.   repeated NetState test_state = 27;  
  143.   
  144.   //测试迭代批次数:  
  145.   //合理设置可使得测试遍历完全部测试样本  
  146.   //合理值 = 测试样本总数/每批次测试数 = totalTestSamples/batchSize  
  147.   repeated int32 test_iter = 3;  
  148.   
  149.   //训练迭代批次数:  
  150.   //两次测试之间所经历的训练迭代次数:合理设置可使得训练遍历完全部训练样本  
  151.   //合理值 = 训练样本总数/每批次训练数 = totalTrainSamples/batchSize  
  152.   optional int32 test_interval = 4 [default = 0];  
  153.   //训练test_interval个批次,再测试test_iter个批次,为一个回合(epoch)  
  154.   //合理设置应使得每个回合内,遍历覆盖到全部训练样本和测试样本  
  155.   
  156.   //默认不计算测试时损失  
  157.   optional bool test_compute_loss = 19 [default = false];  
  158.   
  159.   // 如设置为真,则在训练前运行一次测试,以确保内存足够,并打印初始损失值  
  160.   optional bool test_initialization = 32 [default = true];  
  161.   // 基本学习速率  
  162.   optional float base_lr = 5; // The base learning rate  
  163.   // 打印信息的遍历间隔,遍历多少个批次打印一次信息。设置为0则不打印。  
  164.   optional int32 display = 6;  
  165.   // Display the loss averaged over the last average_loss iterations  
  166.   // 打印最后一个迭代批次下的平均损失(?)  
  167.   optional int32 average_loss = 33 [default = 1];  
  168.   // 训练最大迭代次数  
  169.   optional int32 max_iter = 7;  
  170.   // accumulate gradients over `iter_size` x `batch_size` instances  
  171.   // 累积梯度误差基于“iter_size×batchSize”个样本实例  
  172.   // “批次数×批量数”=“遍历的批次数×每批的样本数”个样本实例  
  173.   optional int32 iter_size = 36 [default = 1];  
  174.   
  175.   //学习率衰减策略(7种)  
  176.   // The learning rate decay policy. The currently implemented learning rate  
  177.   // policies are as follows:  
  178.   //    - fixed: always return base_lr.  
  179.   //    - step: return base_lr * gamma ^ (floor(iter / step))  
  180.   //    - exp: return base_lr * gamma ^ iter  
  181.   //    - inv: return base_lr * (1 + gamma * iter) ^ (- power)  
  182.   //    - multistep: similar to step butallows non uniform steps defined by  
  183.   //      stepvalue  
  184.   //    - poly: the effective learning rate follows a polynomial decay, to be  
  185.   //      zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power)  
  186.   //    - sigmoid: the effective learning rate follows a sigmod decay  
  187.   //      return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize))))  
  188.   //  
  189.   // 在上述参数中,base_lr, max_iter, gamma, step, stepvalue and power 被定义  
  190.   // 在solver.prototxt文件中,iter是当前迭代次数。  
  191.   optional string lr_policy = 8; //学习率调节策略  
  192.   optional float gamma = 9; // The parameter to compute the learning rate.  
  193.   optional float power = 10; // The parameter to compute the learning rate.  
  194.   optional float momentum = 11; // The momentum value.动量  
  195.   optional float weight_decay = 12; // The weight decay.权值衰减系数  
  196.   //由权值衰减系数所控制的正则化类型:L1或L2范数,默认L2  
  197.   optional string regularization_type = 29 [default = "L2"];  
  198.   //"step"策略下,学习率的步长值  
  199.   optional int32 stepsize = 13;  
  200.   //"multistep"策略下的步长值  
  201.   repeated int32 stepvalue = 34;  
  202.   
  203.   //设置梯度裁剪阈值为>=0,当其实际L2范数超出此值时(?)  
  204.   optional float clip_gradients = 35 [default = -1];  
  205.   
  206.   //快照间隔,遍历多少次对模型和求解器状态保存一次  
  207.   optional int32 snapshot = 14 [default = 0]; // The snapshot interval  
  208.   optional string snapshot_prefix = 15; // The prefix for the snapshot.  
  209.   //是否对diff快照,有助调试,但最终的protocol buffer尺寸会很大  
  210.   optional bool snapshot_diff = 16 [default = false];  
  211.   //快照数据保存格式{hdf5,binaryproto(默认)}  
  212.   enum SnapshotFormat {  
  213.     HDF5 = 0;  
  214.     BINARYPROTO = 1;  
  215.   }  
  216.   optional SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];  
  217.   // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default.  
  218.   enum SolverMode {  
  219.     CPU = 0;  
  220.     GPU = 1;  
  221.   }  
  222.   求解模式{GPU(device_id),CPU}  
  223.   optional SolverMode solver_mode = 17 [default = GPU];  
  224.   optional int32 device_id = 18 [default = 0];  
  225.   //随机数种子,设为正则表示Solver会以此为随机数初始化caffe,可产生重复随机  
  226.   //数,易于重复试验;设为默认-1代表使用系统时钟作为种子。  
  227.   optional int64 random_seed = 20 [default = -1];  
  228.   
  229.   //求解器类型=SGD(默认)  
  230.   optional string type = 40 [default = "SGD"];  
  231.   
  232.   // numerical stability for RMSProp, AdaGrad and AdaDelta and Adam  
  233.   optional float delta = 31 [default = 1e-8];  
  234.   // parameters for the Adam solver  
  235.   optional float momentum2 = 39 [default = 0.999];  
  236.   
  237.   // RMSProp decay value  
  238.   // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t)  
  239.   optional float rms_decay = 38;  
  240.   
  241.   //若真,则打印网络状态信息,有助于调试问题  
  242.   optional bool debug_info = 23 [default = false];  
  243.   
  244.   //若假,则不会在训练后保存快照  
  245.   optional bool snapshot_after_train = 28 [default = true];  
  246.   
  247.   // DEPRECATED: old solver enum types, use string instead  
  248.   enum SolverType {  
  249.     SGD = 0;  
  250.     NESTEROV = 1;  
  251.     ADAGRAD = 2;  
  252.     RMSPROP = 3;  
  253.     ADADELTA = 4;  
  254.     ADAM = 5;  
  255.   }  
  256.   // DEPRECATED: use type instead of solver_type  
  257.   optional SolverType solver_type = 30 [default = SGD];  
  258. }  
  259.   
  260. //对求解器状态进行快照的消息  
  261. message SolverState {  
  262.   optional int32 iter = 1; // The current iteration  
  263.   optional string learned_net = 2; // The file that stores the learned net.  
  264.   repeated BlobProto history = 3; // The history for sgd solvers  
  265.   optional int32 current_step = 4 [default = 0]; // The current step for learning rate  
  266. }  
  267.   
  268. enum Phase {  
  269.    TRAIN = 0;  
  270.    TEST = 1;  
  271. }  
  272. //NetState{phase,level,stage}  
  273. message NetState {  
  274.   optional Phase phase = 1 [default = TEST];  
  275.   optional int32 level = 2 [default = 0];  
  276.   repeated string stage = 3;  
  277. }  
  278.   
  279. //网络状态规则{phases,levels,stages}  
  280. message NetStateRule {  
  281.   //在NetState中设置phase值(TRAIN|TEST),使其符合此规则  
  282.   optional Phase phase = 1;  
  283.   
  284.   //设置layer中所使用的最小最大levels。使其不定义以满足忽视level的规则。  
  285.   optional int32 min_level = 2;  
  286.   optional int32 max_level = 3;  
  287.   
  288.   // Customizable sets of stages to include or exclude.  
  289.   // The net must have ALL of the specified stages and NONE of the specified  
  290.   // "not_stage"s to meet the rule.  
  291.   // (Use multiple NetStateRules to specify conjunctions of stages.)  
  292.   //可定制的stages集合,用于include或exclude在网络中。网络必须包含全  
  293.   //部制定的"stages"或不包含全部制定的"not_stage"  
  294.   repeated string stage = 4;  
  295.   repeated string not_stage = 5;  
  296. }  
  297.   
  298. // Specifies training parameters (multipliers on global learning constants,  
  299. // and the name and other settings used for weight sharing).  
  300. //指定训练参数(乘数及全局学习率常数)和其名称,以及其他用于权值共享的设置。  
  301. message ParamSpec {  
  302.   // 设定参数blobs的名称--用于在层间共享参数,若无此需求则不用设计。  
  303.   optional string name = 1;  
  304.   
  305.   //共享权重时是否需要其形状相同或仅仅数量相同,默认为形状相同  
  306.   optional DimCheckMode share_mode = 2;  
  307.   enum DimCheckMode {  
  308.     // STRICT (default) 形状相同(num, channels, height, width)都匹配.  
  309.     STRICT = 0;  
  310.     // PERMISSIVE 数量相同  
  311.     PERMISSIVE = 1;  
  312.   }  
  313.   
  314.   // The multiplier on the global learning rate for this parameter.  
  315.   // 全局学习率的乘数  
  316.   optional float lr_mult = 3 [default = 1.0];  
  317.   
  318.   // The multiplier on the global weight decay for this parameter.  
  319.   // 全局权值衰减系数的乘数  
  320.   optional float decay_mult = 4 [default = 1.0];  
  321. }  
  322.   
  323. //注意:  
  324. //当在LayerParameter中新增字段时,需要为其更新下一个可用ID。  
  325. //比如,最近新增了smooth_l1_loss_param层,则为其指定层专属ID:149。  
  326. //层参数{名称,类型,输入底,输出顶,阶段,损失加权系数,全局乘数,}  
  327. message LayerParameter {  
  328.   optional string name = 1; // 类名称  
  329.   optional string type = 2; // 类类型  
  330.   repeated string bottom = 3; // the name of each bottom blob 输入blob名称  
  331.   repeated string top = 4; // the name of each top blob 输出blob名称  
  332.   
  333.   // The train / test phase for computation. //阶段,运行时状态  
  334.   optional Phase phase = 10;  
  335.   
  336.   //每层输出blob在目标损失函数中的加权系数,每层默认为0或1  
  337.   repeated float loss_weight = 5;  
  338.   
  339.   //指定训练参数(全局学习率上的乘数lr_mrlt)  
  340.   repeated ParamSpec param = 6;  
  341.   
  342.   
  343.   // The blobs containing the numeric parameters of the layer.  
  344.   //包含每层数值参数的blobs  
  345.   repeated BlobProto blobs = 7;  
  346.   
  347.   // Specifies whether to backpropagate to each bottom. If unspecified,  
  348.   // Caffe will automatically infer whether each input needs backpropagation  
  349.   // to compute parameter gradients. If set to true for some inputs,  
  350.   // backpropagation to those inputs is forced; if set false for some inputs,  
  351.   // backpropagation to those inputs is skipped.  
  352.   //  
  353.   // The size must be either 0 or equal to the number of bottoms.  
  354.   
  355.   repeated bool propagate_down = 11;  
  356.   
  357.   // Rules控制每层是否被包含在网络中,基于当前的NetState. 可使用非0数规则来  
  358.   // include或exclude,但不能兼有。如果未指定include或exclude规则,则该层总是  
  359.   // 被包含在内。  
  360.   repeated NetStateRule include = 8;  
  361.   repeated NetStateRule exclude = 9;  
  362.   
  363.   // 用于数据预处理的参数  
  364.   optional TransformationParameter transform_param = 100;  
  365.   
  366.   // 由loss层共享的参数.  
  367.   optional LossParameter loss_param = 101;  
  368.   
  369.   // Layer type-specific parameters.  
  370.   //  
  371.   // Note: certain layers may have more than one computational engine  
  372.   // for their implementation. These layers include an Engine type and  
  373.   // engine parameter for selecting the implementation.  
  374.   // The default for the engine is set by the ENGINE switch at compile-time.  
  375.   // 层类型指定参数  
  376.   // 注意:  
  377.   optional AccuracyParameter accuracy_param = 102;  
  378.   optional ArgMaxParameter argmax_param = 103;  
  379.   optional BatchNormParameter batch_norm_param = 139;  
  380.   optional BiasParameter bias_param = 141;  
  381.   optional ConcatParameter concat_param = 104;  
  382.   optional ContrastiveLossParameter contrastive_loss_param = 105;  
  383.   optional ConvolutionParameter convolution_param = 106;  
  384.   optional CropParameter crop_param = 144;  
  385.   optional DataParameter data_param = 107;  
  386.   optional DropoutParameter dropout_param = 108;  
  387.   optional DummyDataParameter dummy_data_param = 109;  
  388.   optional EltwiseParameter eltwise_param = 110;  
  389.   optional ELUParameter elu_param = 140;  
  390.   optional EmbedParameter embed_param = 137;  
  391.   optional ExpParameter exp_param = 111;  
  392.   optional FlattenParameter flatten_param = 135;  
  393.   optional HDF5DataParameter hdf5_data_param = 112;  
  394.   optional HDF5OutputParameter hdf5_output_param = 113;  
  395.   optional HingeLossParameter hinge_loss_param = 114;  
  396.   optional ImageDataParameter image_data_param = 115;  
  397.   optional InfogainLossParameter infogain_loss_param = 116;  
  398.   optional InnerProductParameter inner_product_param = 117;  
  399.   optional InputParameter input_param = 143;  
  400.   optional LogParameter log_param = 134;  
  401.   optional LRNParameter lrn_param = 118;  
  402.   optional MemoryDataParameter memory_data_param = 119;  
  403.   optional MVNParameter mvn_param = 120;  
  404.   optional ParameterParameter parameter_param = 145;  
  405.   optional PoolingParameter pooling_param = 121;  
  406.   optional PowerParameter power_param = 122;  
  407.   optional PReLUParameter prelu_param = 131;  
  408.   optional PythonParameter python_param = 130;  
  409.   optional RecurrentParameter recurrent_param = 146;  
  410.   optional ReductionParameter reduction_param = 136;  
  411.   optional ReLUParameter relu_param = 123;  
  412.   optional ReshapeParameter reshape_param = 133;  
  413.   optional ROIPoolingParameter roi_pooling_param = 147;  
  414.   optional ScaleParameter scale_param = 142;  
  415.   optional SigmoidParameter sigmoid_param = 124;  
  416.   optional SmoothL1LossParameter smooth_l1_loss_param = 148;  
  417.   optional SoftmaxParameter softmax_param = 125;  
  418.   optional SPPParameter spp_param = 132;  
  419.   optional SliceParameter slice_param = 126;  
  420.   optional TanHParameter tanh_param = 127;  
  421.   optional ThresholdParameter threshold_param = 128;  
  422.   optional TileParameter tile_param = 138;  
  423.   optional WindowDataParameter window_data_param = 129;  
  424.   optional MILDataParameter mil_data_param = 0x004d4944; //"MID"  
  425.   optional MILParameter mil_param = 0x004d494c; //"MIL"  
  426. }  
  427.   
  428. // 对数据层进行转换的参数  
  429. message TransformationParameter {  
  430.   // 对data执行预处理,比如简单缩放,去均值。  
  431.   optional float scale = 1 [default = 1];  
  432.   // Specify if we want to randomly mirror data.//镜像  
  433.   optional bool mirror = 2 [default = false];  
  434.   // Specify if we would like to randomly crop an image.//随机裁剪  
  435.   optional uint32 crop_size = 3 [default = 0];  
  436.   // 指定均值文件或均值,二者不可兼有;在对应通道上减去此均值;  
  437.   optional string mean_file = 4;  
  438.   repeated float mean_value = 5;  
  439.   // 强制转换图像为3通道彩色  
  440.   optional bool force_color = 6 [default = false];  
  441.   // 强制转换为灰度图  
  442.   optional bool force_gray = 7 [default = false];  
  443. }  
  444.   
  445. // Loss层参数  
  446. message LossParameter {  
  447.   // 如果被指定,则忽略给定label的实例  
  448.   optional int32 ignore_label = 1;  
  449.   // 如何对loss层损失归一化,使其跨越"batches,spatial(H*W)"或其他维度。  
  450.   // 目前仅仅在SoftmaxWithLoss层中实现。  
  451.   // 归一化模式  
  452.   enum NormalizationMode {  
  453.     // 基于batchSize×spatialDim归一化.所设定的忽略标签将不被忽略。  
  454.     FULL = 0;  
  455.     // 基于输出位置的总数量(batchSize×H×W)归一化,不包括被忽视的标签。  
  456.     // 若未设置被忽视标签,则其行为与FULL相同。  
  457.     VALID = 1;  
  458.     // Divide by the batch size.基于batchSize进行归一化。  
  459.     BATCH_SIZE = 2;  
  460.     // Do not normalize the loss.不归一化损失  
  461.     NONE = 3;  
  462.   }  
  463.   optional NormalizationMode normalization = 3 [default = VALID];  
  464.   // 旧版--新版如上所述。  
  465.   // 若"normalization"被指定则忽略此参数;若未被指定,可设置下值为false  
  466.   // 则基于batchSize归一化。  
  467.   optional bool normalize = 2;  
  468. }  
  469.   
  470. // Messages that store parameters used by individual layer types follow, in  
  471. // alphabetical order.  
  472.   
  473. message AccuracyParameter {  
  474.   // When computing accuracy, count as correct by comparing the true label to  
  475.   // the top k scoring classes.  By default, only compare to the top scoring  
  476.   // class (i.e. argmax). //Topk正确率计算  
  477.   optional uint32 top_k = 1 [default = 1];  
  478.   
  479.   // The "label" axis of the prediction blob, whose argmax corresponds to the  
  480.   // predicted label -- may be negative to index from the end (e.g.,-1 for the  
  481.   // last axis).  For example, if axis == 1 and the predictions are  
  482.   // (N x C x H x W), the label blob is expected to contain N*H*W ground truth  
  483.   // labels with integer values in {0, 1, ..., C-1}.  
  484.   // 预测blob的"label"轴--其最大值才对应于预测标签--的索引有可能从负值开始。  
  485.   // 即: predicted_labels=argmax(predictions blob,label_axis)  
  486.   // 比如axis==1,其预测blob为(N x C x H x W), 而标签blob被期望包含(N×H×W)个  
  487.   // 真实标签,且标签值为{0,1,2...C-1}。  
  488.   optional int32 axis = 2 [default = 1];  
  489.   
  490.   // If specified, ignore instances with the given label.  
  491.   // 如果指定,则忽略给定标签的对应实例  
  492.   optional int32 ignore_label = 3;  
  493. }  
  494. //输出最大化参数,对预测标签进行最大化  
  495. message ArgMaxParameter {  
  496.   // If true produce pairs (argmax, maxval)  
  497.   // 如果真,则产生(argmax,maxval)对  
  498.   optional bool out_max_val = 1 [default = false];  
  499.   optional uint32 top_k = 2 [default = 1];  
  500.   // The axis along which to maximise -- may be negative to index from the  
  501.   // end (e.g., -1 for the last axis).  
  502.   // By default ArgMaxLayer maximizes over the flattened trailing dimensions  
  503.   // for each index of the first / num dimension. ??  
  504.   //  
  505.   optional int32 axis = 3;  
  506. }  
  507. //拼接参数  
  508. message ConcatParameter {  
  509.   // The axis along which to concatenate -- may be negative to index from the  
  510.   // end (e.g., -1 for the last axis).  Other axes must have the  
  511.   // same dimension for all the bottom blobs.  
  512.   // By default, ConcatLayer concatenates blobs along the "channels" axis (1).  
  513.   optional int32 axis = 2 [default = 1];  
  514.   
  515.   // DEPRECATED: alias for "axis" -- does not support negative indexing.  
  516.   optional uint32 concat_dim = 1 [default = 1];  
  517. }  
  518. //BatchNormParameter参数,源于论文batchNorm  
  519. message BatchNormParameter {  
  520.   // If false, accumulate global mean/variance values via a moving average. If  
  521.   // true, use those accumulated values instead of computing mean/variance  
  522.   // across the batch.  
  523.   optional bool use_global_stats = 1;  
  524.   // How much does the moving average decay each iteration?  
  525.   optional float moving_average_fraction = 2 [default = .999];  
  526.   // Small value to add to the variance estimate so that we don't divide by  
  527.   // zero.  
  528.   optional float eps = 3 [default = 1e-5];  
  529. }  
  530. //偏置参数  
  531. message BiasParameter {  
  532.   // The first axis of bottom[0] (the first input Blob) along which to apply  
  533.   // bottom[1] (the second input Blob).  May be negative to index from the end  
  534.   // (e.g., -1 for the last axis).  
  535.   //  
  536.   // For example, if bottom[0] is 4D with shape 100x3x40x60, the output  
  537.   // top[0] will have the same shape, and bottom[1] may have any of the  
  538.   // following shapes (for the given value of axis):  
  539.   //    (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60  
  540.   //    (axis == 1 == -3)          3;     3x40;     3x40x60  
  541.   //    (axis == 2 == -2)                   40;       40x60  
  542.   //    (axis == 3 == -1)                                60  
  543.   // Furthermore, bottom[1] may have the empty shape (regardless of the value of  
  544.   // "axis") -- a scalar bias.  
  545.   optional int32 axis = 1 [default = 1];  
  546.   
  547.   // (num_axes is ignored unless just one bottom is given and the bias is  
  548.   // a learned parameter of the layer.  Otherwise, num_axes is determined by the  
  549.   // number of axes by the second bottom.)  
  550.   // The number of axes of the input (bottom[0]) covered by the bias  
  551.   // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.  
  552.   // Set num_axes := 0, to add a zero-axis Blob: a scalar.  
  553.   optional int32 num_axes = 2 [default = 1];  
  554.   
  555.   // (filler is ignored unless just one bottom is given and the bias is  
  556.   // a learned parameter of the layer.)  
  557.   // The initialization for the learned bias parameter.  
  558.   // Default is the zero (0) initialization, resulting in the BiasLayer  
  559.   // initially performing the identity operation.  
  560.   optional FillerParameter filler = 3;  
  561. }  
  562. //对比度损失参数  
  563. message ContrastiveLossParameter {  
  564.   // margin for dissimilar pair  
  565.   optional float margin = 1 [default = 1.0];  
  566.   // The first implementation of this cost did not exactly match the cost of  
  567.   // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2.  
  568.   // legacy_version = false (the default) uses (margin - d)^2 as proposed in the  
  569.   // Hadsell paper. New models should probably use this version.  
  570.   // legacy_version = true uses (margin - d^2). This is kept to support /  
  571.   // reproduce existing models and results  
  572.   optional bool legacy_version = 2 [default = false];  
  573. }  
  574. //卷积参数  
  575. message ConvolutionParameter {  
  576.   optional uint32 num_output = 1; // The number of outputs for the layer  
  577.   optional bool bias_term = 2 [default = true]; // whether to have bias terms  
  578.   
  579.   // Pad, kernel size, and stride are all given as a single value for equal  
  580.   // dimensions in all spatial dimensions, or once per spatial dimension.  
  581.   repeated uint32 pad = 3; // The padding size; defaults to 0  
  582.   repeated uint32 kernel_size = 4; // The kernel size  
  583.   repeated uint32 stride = 6; // The stride; defaults to 1  
  584.   // Factor used to dilate the kernel, (implicitly) zero-filling the resulting  
  585.   // holes. (Kernel dilation is sometimes referred to by its use in the  
  586.   // algorithme 脿 trous from Holschneider et al. 1987.)  
  587.   repeated uint32 dilation = 18; // The dilation; defaults to 1  
  588.   
  589.   // For 2D convolution only, the *_h and *_w versions may also be used to  
  590.   // specify both spatial dimensions.  
  591.   optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only)  
  592.   optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only)  
  593.   optional uint32 kernel_h = 11; // The kernel height (2D only)  
  594.   optional uint32 kernel_w = 12; // The kernel width (2D only)  
  595.   optional uint32 stride_h = 13; // The stride height (2D only)  
  596.   optional uint32 stride_w = 14; // The stride width (2D only)  
  597.   
  598.   optional uint32 group = 5 [default = 1]; // The group size for group conv  
  599.   
  600.   optional FillerParameter weight_filler = 7; // The filler for the weight  
  601.   optional FillerParameter bias_filler = 8; // The filler for the bias  
  602.   enum Engine {  
  603.     DEFAULT = 0; //CPU  
  604.     CAFFE = 1;   //GPU-CUDA  
  605.     CUDNN = 2;   //GPU-CUDA-CUDNN  
  606.   }  
  607.   optional Engine engine = 15 [default = DEFAULT];  
  608.   
  609.   // The axis to interpret as "channels" when performing convolution.  
  610.   // Preceding dimensions are treated as independent inputs;  
  611.   // succeeding dimensions are treated as "spatial".  
  612.   // With (N, C, H, W) inputs, and axis == 1 (the default), we perform  
  613.   // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for  
  614.   // groups g>1) filters across the spatial axes (H, W) of the input.  
  615.   // With (N, C, D, H, W) inputs, and axis == 1, we perform  
  616.   // N independent 3D convolutions, sliding (C/g)-channels  
  617.   // filters across the spatial axes (D, H, W) of the input.  
  618.   optional int32 axis = 16 [default = 1];  
  619.   
  620.   // Whether to force use of the general ND convolution, even if a specific  
  621.   // implementation for blobs of the appropriate number of spatial dimensions  
  622.   // is available. (Currently, there is only a 2D-specific convolution  
  623.   // implementation; for input blobs with num_axes != 2, this option is  
  624.   // ignored and the ND implementation will be used.)  
  625.   optional bool force_nd_im2col = 17 [default = false];  
  626. }  
  627. //裁剪参数  
  628. message CropParameter {  
  629.   // To crop, elements of the first bottom are selected to fit the dimensions  
  630.   // of the second, reference bottom. The crop is configured by  
  631.   // - the crop `axis` to pick the dimensions for cropping  
  632.   // - the crop `offset` to set the shift for all/each dimension  
  633.   // to align the cropped bottom with the reference bottom.  
  634.   // All dimensions up to but excluding `axis` are preserved, while  
  635.   // the dimensions including and trailing `axis` are cropped.  
  636.   // If only one `offset` is set, then all dimensions are offset by this amount.  
  637.   // Otherwise, the number of offsets must equal the number of cropped axes to  
  638.   // shift the crop in each dimension accordingly.  
  639.   // Note: standard dimensions are N,C,H,W so the default is a spatial crop,  
  640.   // and `axis` may be negative to index from the end (e.g., -1 for the last  
  641.   // axis).  
  642.   optional int32 axis = 1 [default = 2];  
  643.   repeated uint32 offset = 2;  
  644. }  
  645. //数据参数  
  646. message DataParameter {  
  647.   enum DB {  
  648.     LEVELDB = 0;  
  649.     LMDB = 1;  
  650.   }  
  651.   // Specify the data source.  
  652.   optional string source = 1;  
  653.   // Specify the batch size.  
  654.   optional uint32 batch_size = 4;  
  655.   // The rand_skip variable is for the data layer to skip a few data points  
  656.   // to avoid all asynchronous sgd clients to start at the same point. The skip  
  657.   // point would be set as rand_skip * rand(0,1). Note that rand_skip should not  
  658.   // be larger than the number of keys in the database.  
  659.   // DEPRECATED. Each solver accesses a different subset of the database.  
  660.   optional uint32 rand_skip = 7 [default = 0];  
  661.   optional DB backend = 8 [default = LEVELDB];  
  662.   // DEPRECATED. See TransformationParameter. For data pre-processing, we can do  
  663.   // simple scaling and subtracting the data mean, if provided. Note that the  
  664.   // mean subtraction is always carried out before scaling.  
  665.   optional float scale = 2 [default = 1];  
  666.   optional string mean_file = 3;  
  667.   // DEPRECATED. See TransformationParameter. Specify if we would like to randomly  
  668.   // crop an image.  
  669.   optional uint32 crop_size = 5 [default = 0];  
  670.   // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror  
  671.   // data.  
  672.   optional bool mirror = 6 [default = false];  
  673.   // Force the encoded image to have 3 color channels  
  674.   optional bool force_encoded_color = 9 [default = false];  
  675.   // Prefetch queue (Number of batches to prefetch to host memory, increase if  
  676.   // data access bandwidth varies).  
  677.   optional uint32 prefetch = 10 [default = 4];  
  678. }  
  679. //DropoutParameter参数  
  680. message DropoutParameter {  
  681.   optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio  
  682.   optional bool scale_train = 2 [default = true];  // scale train or test phase  
  683. }  
  684.   
  685. // DummyDataLayer fills any number of arbitrarily shaped blobs with random  
  686. // (or constant) data generated by "Fillers" (see "message FillerParameter").  
  687. message DummyDataParameter {  
  688.   // This layer produces N >= 1 top blobs.  DummyDataParameter must specify 1 or N  
  689.   // shape fields, and 0, 1 or N data_fillers.  
  690.   //  
  691.   // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used.  
  692.   // If 1 data_filler is specified, it is applied to all top blobs.  If N are  
  693.   // specified, the ith is applied to the ith top blob.  
  694.   repeated FillerParameter data_filler = 1;  
  695.   repeated BlobShape shape = 6;  
  696.   
  697.   // 4D dimensions -- deprecated.  Use "shape" instead.  
  698.   repeated uint32 num = 2;  
  699.   repeated uint32 channels = 3;  
  700.   repeated uint32 height = 4;  
  701.   repeated uint32 width = 5;  
  702. }  
  703.   
  704. message EltwiseParameter {  
  705.   enum EltwiseOp {  
  706.     PROD = 0;  
  707.     SUM = 1;  
  708.     MAX = 2;  
  709.   }  
  710.   optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation  
  711.   repeated float coeff = 2; // blob-wise coefficient for SUM operation  
  712.   
  713.   // Whether to use an asymptotically slower (for >2 inputs) but stabler method  
  714.   // of computing the gradient for the PROD operation. (No effect for SUM op.)  
  715.   optional bool stable_prod_grad = 3 [default = true];  
  716. }  
  717.   
  718. // Message that stores parameters used by ELULayer  
  719. message ELUParameter {  
  720.   // Described in:  
  721.   // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate  
  722.   // Deep Network Learning by Exponential Linear Units (ELUs). arXiv  
  723.   optional float alpha = 1 [default = 1];  
  724. }  
  725.   
  726. // Message that stores parameters used by EmbedLayer  
  727. message EmbedParameter {  
  728.   optional uint32 num_output = 1; // The number of outputs for the layer  
  729.   // The input is given as integers to be interpreted as one-hot  
  730.   // vector indices with dimension num_input.  Hence num_input should be  
  731.   // 1 greater than the maximum possible input value.  
  732.   optional uint32 input_dim = 2;  
  733.   
  734.   optional bool bias_term = 3 [default = true]; // Whether to use a bias term  
  735.   optional FillerParameter weight_filler = 4; // The filler for the weight  
  736.   optional FillerParameter bias_filler = 5; // The filler for the bias  
  737.   
  738. }  
  739.   
  740. // Message that stores parameters used by ExpLayer  
  741. message ExpParameter {  
  742.   // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0.  
  743.   // Or if base is set to the default (-1), base is set to e,  
  744.   // so y = exp(shift + scale * x).  
  745.   optional float base = 1 [default = -1.0];  
  746.   optional float scale = 2 [default = 1.0];  
  747.   optional float shift = 3 [default = 0.0];  
  748. }  
  749.   
  750. /// Message that stores parameters used by FlattenLayer  
  751. message FlattenParameter {  
  752.   // The first axis to flatten: all preceding axes are retained in the output.  
  753.   // May be negative to index from the end (e.g., -1 for the last axis).  
  754.   optional int32 axis = 1 [default = 1];  
  755.   
  756.   // The last axis to flatten: all following axes are retained in the output.  
  757.   // May be negative to index from the end (e.g., the default -1 for the last  
  758.   // axis).  
  759.   optional int32 end_axis = 2 [default = -1];  
  760. }  
  761.   
  762. // Message that stores parameters used by HDF5DataLayer  
  763. message HDF5DataParameter {  
  764.   // Specify the data source.  
  765.   optional string source = 1;  
  766.   // Specify the batch size.  
  767.   optional uint32 batch_size = 2;  
  768.   
  769.   // Specify whether to shuffle the data.  
  770.   // If shuffle == true, the ordering of the HDF5 files is shuffled,  
  771.   // and the ordering of data within any given HDF5 file is shuffled,  
  772.   // but data between different files are not interleaved; all of a file's  
  773.   // data are output (in a random order) before moving onto another file.  
  774.   optional bool shuffle = 3 [default = false];  
  775. }  
  776.   
  777. message HDF5OutputParameter {  
  778.   optional string file_name = 1;  
  779. }  
  780.   
  781. message HingeLossParameter {  
  782.   enum Norm {  
  783.     L1 = 1;  
  784.     L2 = 2;  
  785.   }  
  786.   // Specify the Norm to use L1 or L2  
  787.   optional Norm norm = 1 [default = L1];  
  788. }  
  789. //数据集参数  
  790. message ImageDataParameter {  
  791.   // 指定数据源文件  
  792.   optional string source = 1;  
  793.   // 指定批量大小batchSize  
  794.   optional uint32 batch_size = 4 [default = 1];  
  795.   // The rand_skip variable is for the data layer to skip a few data points  
  796.   // to avoid all asynchronous sgd clients to start at the same point. The skip  
  797.   // point would be set as rand_skip * rand(0,1). Note that rand_skip should not  
  798.   // be larger than the number of keys in the database.  
  799.   // 随机跳过rand_skip * rand(0,1)个样本,以使得SGD从不同状态点启动  
  800.   optional uint32 rand_skip = 7 [default = 0];  
  801.   // Whether or not ImageLayer should shuffle the list of files at every epoch.是否在每个回合都混排图片,默认否  
  802.   optional bool shuffle = 8 [default = false];  
  803.   // It will also resize images if new_height or new_width are not zero.  
  804.   // 若以下2个值不为0,则将图片缩放为下面的形状  
  805.   optional uint32 new_height = 9 [default = 0];  
  806.   optional uint32 new_width = 10 [default = 0];  
  807.   // Specify if the images are color or gray指明是彩色还是灰度图  
  808.   optional bool is_color = 11 [default = true];  
  809.   // DEPRECATED. See TransformationParameter. For data pre-processing, we can do  
  810.   // simple scaling and subtracting the data mean, if provided. Note that the  
  811.   // mean subtraction is always carried out before scaling.  
  812.   // 旧版--图片预处理参数,新版用TransformationParameter  
  813.   optional float scale = 2 [default = 1];  
  814.   optional string mean_file = 3;  
  815.   // DEPRECATED. See TransformationParameter. Specify if we would like to randomly  
  816.   // crop an image.  
  817.   optional uint32 crop_size = 5 [default = 0];  
  818.   // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror  
  819.   // data.  
  820.   optional bool mirror = 6 [default = false];  
  821.   optional string root_folder = 12 [default = ""];  
  822. }  
  823. //信息增益损失参数  
  824. message InfogainLossParameter {  
  825.   // Specify the infogain matrix source.  
  826.   optional string source = 1;  
  827. }  
  828. //内积参数  
  829. message InnerProductParameter {  
  830.   optional uint32 num_output = 1; // The number of outputs for the layer  
  831.   optional bool bias_term = 2 [default = true]; // whether to have bias terms  
  832.   optional FillerParameter weight_filler = 3; // The filler for the weight  
  833.   optional FillerParameter bias_filler = 4; // The filler for the bias  
  834.   
  835.   // The first axis to be lumped into a single inner product computation;  
  836.   // all preceding axes are retained in the output.  
  837.   // May be negative to index from the end (e.g., -1 for the last axis).  
  838.   optional int32 axis = 5 [default = 1];  
  839.   // Specify whether to transpose the weight matrix or not.  
  840.   // If transpose == true, any operations will be performed on the transpose  
  841.   // of the weight matrix. The weight matrix itself is not going to be transposed  
  842.   // but rather the transfer flag of operations will be toggled accordingly.  
  843.   optional bool transpose = 6 [default = false];  
  844. }  
  845. //输入参数  
  846. message InputParameter {  
  847.   // This layer produces N >= 1 top blob(s) to be assigned manually.  
  848.   // Define N shapes to set a shape for each top.  
  849.   // Define 1 shape to set the same shape for every top.  
  850.   // Define no shape to defer to reshaping manually.  
  851.   // 此层管理输入(top)blobs,当输入blob个数N≥1,可使其自动分配。  
  852.   // 设定N个shapes为N个输入blob;设定1个shape使得全部输入blob形状相同;  
  853.   // 不设定,可手动调整。  
  854.   // 可查看.\models\bvlc_reference_caffenet\deploy.prototxt中指定1个shape  
  855.   repeated BlobShape shape = 1;  
  856. }  
  857.   
  858. // LogLayer的参数  
  859. message LogParameter {  
  860.   // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0.  
  861.   // Or if base is set to the default (-1), base is set to e,  
  862.   // so y = ln(shift + scale * x) = log_e(shift + scale * x)  
  863.   optional float base = 1 [default = -1.0];  
  864.   optional float scale = 2 [default = 1.0];  
  865.   optional float shift = 3 [default = 0.0];  
  866. }  
  867.   
  868. // LRNLayer层参数  
  869. message LRNParameter {  
  870.   optional uint32 local_size = 1 [default = 5];  
  871.   optional float alpha = 2 [default = 1.];  
  872.   optional float beta = 3 [default = 0.75];  
  873.   enum NormRegion {  
  874.     ACROSS_CHANNELS = 0;  
  875.     WITHIN_CHANNEL = 1;  
  876.   }  
  877.   optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS];  
  878.   optional float k = 5 [default = 1.];  
  879.   enum Engine {  
  880.     DEFAULT = 0;  
  881.     CAFFE = 1;  
  882.     CUDNN = 2;  
  883.   }  
  884.   optional Engine engine = 6 [default = DEFAULT];  
  885. }  
  886.   
  887. //数据内存占用参数  
  888. message MemoryDataParameter {  
  889.   optional uint32 batch_size = 1;  
  890.   optional uint32 channels = 2;  
  891.   optional uint32 height = 3;  
  892.   optional uint32 width = 4;  
  893. }  
  894. //MVN参数{均值,方差,跨通道}(mean-varance-normalization)  
  895. message MVNParameter {  
  896.   // This parameter can be set to false to normalize mean only  
  897.   // 设定为false时仅归一化均值,否则包括方差  
  898.   optional bool normalize_variance = 1 [default = true];  
  899.   
  900.   // This parameter can be set to true to perform DNN-like MVN  
  901.   // 执行跨通道归一化,类似于DNN的MVN;默认否,只执行Spatial内归一化。  
  902.   optional bool across_channels = 2 [default = false];  
  903.   
  904.   // Epsilon for not dividing by zero while normalizing variance  
  905.   // 防止除0的极小数  
  906.   optional float eps = 3 [default = 1e-9];  
  907. }  
  908.   
  909. //??  
  910. message ParameterParameter {  
  911.   optional BlobShape shape = 1;  
  912. }  
  913. //池化层参数  
  914. message PoolingParameter {  
  915.   enum PoolMethod {  
  916.     MAX = 0;  
  917.     AVE = 1;  
  918.     STOCHASTIC = 2;  
  919.   }  
  920.   optional PoolMethod pool = 1 [default = MAX]; // The pooling method  
  921.   // Pad, kernel size, and stride are all given as a single value for equal  
  922.   // dimensions in height and width or as Y, X pairs.  
  923.   optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X)  
  924.   optional uint32 pad_h = 9 [default = 0]; // The padding height  
  925.   optional uint32 pad_w = 10 [default = 0]; // The padding width  
  926.   optional uint32 kernel_size = 2; // The kernel size (square)  
  927.   optional uint32 kernel_h = 5; // The kernel height  
  928.   optional uint32 kernel_w = 6; // The kernel width  
  929.   optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X)  
  930.   optional uint32 stride_h = 7; // The stride height  
  931.   optional uint32 stride_w = 8; // The stride width  
  932.   enum Engine {  
  933.     DEFAULT = 0;  
  934.     CAFFE = 1;  
  935.     CUDNN = 2;  
  936.   }  
  937.   optional Engine engine = 11 [default = DEFAULT];  
  938.   // If global_pooling then it will pool over the size of the bottom by doing  
  939.   // kernel_h = bottom->height and kernel_w = bottom->width  
  940.   optional bool global_pooling = 12 [default = false];  
  941. }  
  942.   
  943. message PowerParameter {  
  944.   // PowerLayer computes outputs y = (shift + scale * x) ^ power.  
  945.   optional float power = 1 [default = 1.0];  
  946.   optional float scale = 2 [default = 1.0];  
  947.   optional float shift = 3 [default = 0.0];  
  948. }  
  949. //Python参数  
  950. message PythonParameter {  
  951.   optional string module = 1;  
  952.   optional string layer = 2;  
  953.   // This value is set to the attribute `param_str` of the `PythonLayer` object  
  954.   // in Python before calling the `setup()` method. This could be a number,  
  955.   // string, dictionary in Python dict format, JSON, etc. You may parse this  
  956.   // string in `setup` method and use it in `forward` and `backward`.  
  957.   optional string param_str = 3 [default = ''];  
  958.   // Whether this PythonLayer is shared among worker solvers during data parallelism.  
  959.   // If true, each worker solver sequentially run forward from this layer.  
  960.   // This value should be set true if you are using it as a data layer.  
  961.   optional bool share_in_parallel = 4 [default = false];  
  962. }  
  963.   
  964. // RecurrentLayer参数  
  965. message RecurrentParameter {  
  966.   // 输出表示的维度必须是非0的  
  967.   optional uint32 num_output = 1 [default = 0];  
  968.   
  969.   optional FillerParameter weight_filler = 2; //weight权值参数  
  970.   optional FillerParameter bias_filler = 3;   //bias偏置参数  
  971.   
  972.   // Whether to enable displaying debug_info in the unrolled recurrent net.  
  973.   // 在展开RCNN时是否打印deuginfo  
  974.   optional bool debug_info = 4 [default = false];  
  975.   
  976.   // Whether to add as additional inputs (bottoms) the initial hidden state  
  977.   // blobs, and add as additional outputs (tops) the final timestep hidden state  
  978.   // blobs.  The number of additional bottom/top blobs required depends on the  
  979.   // recurrent architecture -- e.g., 1 for RNNs, 2 for LSTMs.  
  980.   // 是否添加初始化的隐藏blobs作为额外输入(bottoms),以及添加最终的timestep隐  
  981.   // 藏blobs作为额外输出(tops)。  
  982.   optional bool expose_hidden = 5 [default = false];  
  983. }  
  984.   
  985. // ReductionLayer参数  
  986. message ReductionParameter {  
  987.   enum ReductionOp {  
  988.     SUM = 1;  
  989.     ASUM = 2;  
  990.     SUMSQ = 3;  
  991.     MEAN = 4;  
  992.   }  
  993.   
  994.   optional ReductionOp operation = 1 [default = SUM]; // reduction operation  
  995.   
  996.   // The first axis to reduce to a scalar -- may be negative to index from the  
  997.   // end (e.g., -1 for the last axis).  
  998.   // (Currently, only reduction along ALL "tail" axes is supported; reduction  
  999.   // of axis M through N, where N < num_axes - 1, is unsupported.)  
  1000.   // Suppose we have an n-axis bottom Blob with shape:  
  1001.   //     (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)).  
  1002.   // If axis == m, the output Blob will have shape  
  1003.   //     (d0, d1, d2, ..., d(m-1)),  
  1004.   // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1))  
  1005.   // times, each including (dm * d(m+1) * ... * d(n-1)) individual data.  
  1006.   // If axis == 0 (the default), the output Blob always has the empty shape  
  1007.   // (count 1), performing reduction across the entire input --  
  1008.   // often useful for creating new loss functions.  
  1009.   optional int32 axis = 2 [default = 0];  
  1010.   
  1011.   optional float coeff = 3 [default = 1.0]; // coefficient for output  
  1012. }  
  1013.   
  1014. // ReLULayer参数  
  1015. message ReLUParameter {  
  1016.   // 允许非0斜率可以加速优化:  
  1017.   // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities  
  1018.   // improve neural network acoustic models. In ICML Workshop on Deep Learning  
  1019.   // for Audio, Speech, and Language Processing.  
  1020.   optional float negative_slope = 1 [default = 0];  
  1021.   enum Engine {  
  1022.     DEFAULT = 0;  
  1023.     CAFFE = 1;  
  1024.     CUDNN = 2;  
  1025.   }  
  1026.   optional Engine engine = 2 [default = DEFAULT];  
  1027. }  
  1028.   
  1029. message ReshapeParameter {  
  1030.   // Specify the output dimensions. If some of the dimensions are set to 0,  
  1031.   // the corresponding dimension from the bottom layer is used (unchanged).  
  1032.   // Exactly one dimension may be set to -1, in which case its value is  
  1033.   // inferred from the count of the bottom blob and the remaining dimensions.  
  1034.   // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8:  
  1035.   //  
  1036.   //   layer {  
  1037.   //     type: "Reshape" bottom: "input" top: "output"  
  1038.   //     reshape_param { ... }  
  1039.   //   }  
  1040.   //  
  1041.   // If "input" is 2D with shape 2 x 8, then the following reshape_param  
  1042.   // specifications are all equivalent, producing a 3D blob "output" with shape  
  1043.   // 2 x 2 x 4:  
  1044.   //  
  1045.   //   reshape_param { shape { dim:  2  dim: 2  dim:  4 } }  
  1046.   //   reshape_param { shape { dim:  0  dim: 2  dim:  4 } }  
  1047.   //   reshape_param { shape { dim:  0  dim: 2  dim: -1 } }  
  1048.   //   reshape_param { shape { dim:  0  dim:-1  dim:  4 } }  
  1049.   //  
  1050.   optional BlobShape shape = 1;  
  1051.   
  1052.   // axis and num_axes control the portion of the bottom blob's shape that are  
  1053.   // replaced by (included in) the reshape. By default (axis == 0 and  
  1054.   // num_axes == -1), the entire bottom blob shape is included in the reshape,  
  1055.   // and hence the shape field must specify the entire output shape.  
  1056.   //  
  1057.   // axis may be non-zero to retain some portion of the beginning of the input  
  1058.   // shape (and may be negative to index from the end; e.g., -1 to begin the  
  1059.   // reshape after the last axis, including nothing in the reshape,  
  1060.   // -2 to include only the last axis, etc.).  
  1061.   //  
  1062.   // For example, suppose "input" is a 2D blob with shape 2 x 8.  
  1063.   // Then the following ReshapeLayer specifications are all equivalent,  
  1064.   // producing a blob "output" with shape 2 x 2 x 4:  
  1065.   //  
  1066.   //   reshape_param { shape { dim: 2  dim: 2  dim: 4 } }  
  1067.   //   reshape_param { shape { dim: 2  dim: 4 } axis:  1 }  
  1068.   //   reshape_param { shape { dim: 2  dim: 4 } axis: -3 }  
  1069.   //  
  1070.   // num_axes specifies the extent of the reshape.  
  1071.   // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on  
  1072.   // input axes in the range [axis, axis+num_axes].  
  1073.   // num_axes may also be -1, the default, to include all remaining axes  
  1074.   // (starting from axis).  
  1075.   //  
  1076.   // For example, suppose "input" is a 2D blob with shape 2 x 8.  
  1077.   // Then the following ReshapeLayer specifications are equivalent,  
  1078.   // producing a blob "output" with shape 1 x 2 x 8.  
  1079.   //  
  1080.   //   reshape_param { shape { dim:  1  dim: 2  dim:  8 } }  
  1081.   //   reshape_param { shape { dim:  1  dim: 2  }  num_axes: 1 }  
  1082.   //   reshape_param { shape { dim:  1  }  num_axes: 0 }  
  1083.   //  
  1084.   // On the other hand, these would produce output blob shape 2 x 1 x 8:  
  1085.   //  
  1086.   //   reshape_param { shape { dim: 2  dim: 1  dim: 8  }  }  
  1087.   //   reshape_param { shape { dim: 1 }  axis: 1  num_axes: 0 }  
  1088.   //  
  1089.   optional int32 axis = 2 [default = 0];  
  1090.   optional int32 num_axes = 3 [default = -1];  
  1091. }  
  1092.   
  1093. // ROIPoolingLayer参数  
  1094. message ROIPoolingParameter {  
  1095.   // Pad, kernel size, and stride are all given as a single value for equal  
  1096.   // dimensions in height and width or as Y, X pairs.  
  1097.   optional uint32 pooled_h = 1 [default = 0]; // The pooled output height  
  1098.   optional uint32 pooled_w = 2 [default = 0]; // The pooled output width  
  1099.   // Multiplicative spatial scale factor to translate ROI coords from their  
  1100.   // input scale to the scale used when pooling  
  1101.   optional float spatial_scale = 3 [default = 1];  
  1102. }  
  1103. //ScaleParameter参数  
  1104. message ScaleParameter {  
  1105.   // The first axis of bottom[0] (the first input Blob) along which to apply  
  1106.   // bottom[1] (the second input Blob).  May be negative to index from the end  
  1107.   // (e.g., -1 for the last axis).  
  1108.   // ???????????????????????????????  
  1109.   // 第一个输入Blob的首axis,被应用到第二个输入Blob。但第2个Blob的形状可能不同  
  1110.   // For example, if bottom[0] is 4D with shape 100x3x40x60, the output  
  1111.   // top[0] will have the same shape, and bottom[1] may have any of the  
  1112.   // following shapes (for the given value of axis):  
  1113.   //    (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60  
  1114.   //    (axis == 1 == -3)          3;     3x40;     3x40x60  
  1115.   //    (axis == 2 == -2)                   40;       40x60  
  1116.   //    (axis == 3 == -1)                                60  
  1117.   // Furthermore,bottom[1]may have the empty shape (regardless of the value of  
  1118.   // "axis") -- a scalar multiplier.  
  1119.   optional int32 axis = 1 [default = 1];  
  1120.   
  1121.   // (num_axes is ignored unless just one bottom is given and the scale is  
  1122.   // a learned parameter of the layer.  Otherwise, num_axes is determined by the  
  1123.   // number of axes by the second bottom.)  
  1124.   // The number of axes of the input (bottom[0]) covered by the scale  
  1125.   // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.  
  1126.   // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar.  
  1127.   optional int32 num_axes = 2 [default = 1];  
  1128.   
  1129.   // (filler is ignored unless just one bottom is given and the scale is  
  1130.   // a learned parameter of the layer.)  
  1131.   // The initialization for the learned scale parameter.  
  1132.   // Default is the unit (1) initialization, resulting in the ScaleLayer  
  1133.   // initially performing the identity operation.  
  1134.   optional FillerParameter filler = 3;  
  1135.   
  1136.   // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but  
  1137.   // may be more efficient).  Initialized with bias_filler (defaults to 0).  
  1138.   optional bool bias_term = 4 [default = false];  
  1139.   optional FillerParameter bias_filler = 5;  
  1140. }  
  1141. //SigmoidParameter参数  
  1142. message SigmoidParameter {  
  1143.   enum Engine {  
  1144.     DEFAULT = 0;  
  1145.     CAFFE = 1;  
  1146.     CUDNN = 2;  
  1147.   }  
  1148.   optional Engine engine = 1 [default = DEFAULT];  
  1149. }  
  1150. //SliceParameter参数  
  1151. message SliceParameter {  
  1152.   // The axis along which to slice -- may be negative to index from the end  
  1153.   // (e.g., -1 for the last axis).  
  1154.   // By default, SliceLayer concatenates blobs along the "channels" axis (1).  
  1155.   optional int32 axis = 3 [default = 1];  
  1156.   repeated uint32 slice_point = 2;  
  1157.   
  1158.   // DEPRECATED: alias for "axis" -- does not support negative indexing.  
  1159.   optional uint32 slice_dim = 1 [default = 1];  
  1160. }  
  1161. //SmoothL1LossParameter参数  
  1162. message SmoothL1LossParameter {  
  1163.   // SmoothL1Loss(x) =  
  1164.   //   0.5 * (sigma * x) ** 2    -- if x < 1.0 / sigma / sigma  
  1165.   //   |x| - 0.5 / sigma / sigma -- otherwise  
  1166.   optional float sigma = 1 [default = 1];  
  1167. }  
  1168.   
  1169. //SoftmaxLayer, SoftmaxWithLossLayer的参数  
  1170. message SoftmaxParameter {  
  1171.   enum Engine {  
  1172.     DEFAULT = 0;  
  1173.     CAFFE = 1;  
  1174.     CUDNN = 2;  
  1175.   }  
  1176.   optional Engine engine = 1 [default = DEFAULT];  
  1177.   
  1178.   // The axis along which to perform the softmax -- may be negative to index  
  1179.   // from the end (e.g., -1 for the last axis).  
  1180.   // Any other axes will be evaluated as independent softmaxes.  
  1181.   // 沿着哪一个轴运用softmax,该轴上必须是相互独立的分量。  
  1182.   // eg.预测时对类标签运用,计算损失时对每个类的对数损失运用。  
  1183.   optional int32 axis = 2 [default = 1];  
  1184. }  
  1185. //TanHParameter参数  
  1186. message TanHParameter {  
  1187.   enum Engine {  
  1188.     DEFAULT = 0;  
  1189.     CAFFE = 1;  
  1190.     CUDNN = 2;  
  1191.   }  
  1192.   optional Engine engine = 1 [default = DEFAULT];  
  1193. }  
  1194.   
  1195. // TileLayer参数  
  1196. message TileParameter {  
  1197.   // The index of the axis to tile.  
  1198.   optional int32 axis = 1 [default = 1];  
  1199.   
  1200.   // The number of copies (tiles) of the blob to output.  
  1201.   optional int32 tiles = 2;  
  1202. }  
  1203.   
  1204. // ThresholdLayer参数  
  1205. message ThresholdParameter {  
  1206.   optional float threshold = 1 [default = 0]; // Strictly positive values  
  1207. }  
  1208.   
  1209. // MILLayer参数  
  1210. message MILParameter {  
  1211.   enum MILType {  
  1212.     MAX = 0;  
  1213.     NOR = 1;  
  1214.   }  
  1215.   optional MILType type = 1 [default = MAX]; // The MIL method  
  1216. }  
  1217.   
  1218. //窗口数据参数:专用于目标检测或分割  
  1219. message WindowDataParameter {  
  1220.   // Specify the data source.指定数据源  
  1221.   optional string source = 1;  
  1222.   // 数据预处理:尺度缩放,去均值等。去均值应在缩放前执行。  
  1223.   optional float scale = 2 [default = 1];  
  1224.   optional string mean_file = 3;  
  1225.   // 指定批处理的数据量  
  1226.   optional uint32 batch_size = 4;  
  1227.   // 是否随机裁剪  
  1228.   optional uint32 crop_size = 5 [default = 0];  
  1229.   // 是否镜像变换  
  1230.   optional bool mirror = 6 [default = false];  
  1231.   // Foreground (object) overlap threshold 前景目标重合阈值  
  1232.   optional float fg_threshold = 7 [default = 0.5];  
  1233.   // Background (non-object) overlap threshold背景重合阈值  
  1234.   optional float bg_threshold = 8 [default = 0.5];  
  1235.   // Fraction of batch that should be foreground objects  
  1236.   // 前景目标在batch中的比例  
  1237.   optional float fg_fraction = 9 [default = 0.25];  
  1238.   // Amount of contextual padding to add around a window  
  1239.   // (used only by the window_data_layer)  
  1240.   // 窗口周边需要添加的上下文padding  
  1241.   optional uint32 context_pad = 10 [default = 0];  
  1242.   // Mode for cropping out a detection window  
  1243.   // warp: cropped window is warped to a fixed size and aspect ratio  
  1244.   // square: the tightest square around the window is cropped  
  1245.   // mode:裁剪出一个检测窗口的模式  
  1246.   // warp:裁剪窗口被扭曲为某个固定尺寸和形状  
  1247.   // square:裁剪窗口周边最紧?的方框  
  1248.   optional string crop_mode = 11 [default = "warp"];  
  1249.   // cache_images: will load all images in memory for faster access  
  1250.   //将全部图像(裁剪得到的小图像)放入内存以便快速存取  
  1251.   optional bool cache_images = 12 [default = false];  
  1252.   // append root_folder to locate images  
  1253.   // 添加根文件夹以定位文件  
  1254.   optional string root_folder = 13 [default = ""];  
  1255. }  
  1256. //MILDataParameter参数  
  1257. message MILDataParameter {  
  1258.   // Specify the data source.  
  1259.   optional string source = 1;  
  1260.   
  1261.   // Number of scales for each image  
  1262.   optional uint32 num_scales = 2 [default = 1];  
  1263.   
  1264.   // Side length ratio between neighbouring scales  
  1265.   optional float scale_factor = 6 [default = 1];  
  1266.   
  1267.   // Number of channels in the image  
  1268.   optional uint32 channels = 4 [default = 3];  
  1269.   
  1270.   // Specify the number of images per batch  
  1271.   optional uint32 images_per_batch = 3;  
  1272.   // Specify the number of classes  
  1273.   optional uint32 n_classes = 5;  
  1274.   // specify the box_dir and label_dir  
  1275.   optional string label_file = 7;  
  1276.   
  1277.   // Root directory which contains all the images  
  1278.   optional string root_dir = 11;  
  1279.   // Extention for the file  
  1280.   optional string ext = 12;  
  1281.   
  1282.   // To randomize or not  
  1283.   optional bool randomize = 13 [default = true];  
  1284. }  
  1285.   
  1286. //SPP参数,源于论文SPPNet  
  1287. message SPPParameter {  
  1288.   enum PoolMethod {  
  1289.     MAX = 0;  
  1290.     AVE = 1;  
  1291.     STOCHASTIC = 2;  
  1292.   } //池化方法,获得金字塔的方法,最大/平均/随机  
  1293.   optional uint32 pyramid_height = 1; //金字塔高度  
  1294.   optional PoolMethod pool = 2 [default = MAX]; // The pooling method  
  1295.   enum Engine {  
  1296.     DEFAULT = 0;  
  1297.     CAFFE = 1;  
  1298.     CUDNN = 2;  
  1299.   }  
  1300.   optional Engine engine = 6 [default = DEFAULT];  
  1301. }  
  1302.   
  1303. // DEPRECATED: use LayerParameter.  
  1304. // 旧版:使用层参数。 V1可能是第一版version1的意思  
  1305. message V1LayerParameter {  
  1306.   repeated string bottom = 2;  //输入  
  1307.   repeated string top = 3;     //输出  
  1308.   optional string name = 4;    //层名称  
  1309.   repeated NetStateRule include = 32; //运行时状态:包含  
  1310.   repeated NetStateRule exclude = 33; //运行时状态:不包含  
  1311.   enum LayerType {             //层类型  
  1312.     NONE = 0;  
  1313.     ABSVAL = 35;  
  1314.     ACCURACY = 1;  
  1315.     ARGMAX = 30;  
  1316.     BNLL = 2;  
  1317.     CONCAT = 3;  
  1318.     CONTRASTIVE_LOSS = 37;  
  1319.     CONVOLUTION = 4;  
  1320.     DATA = 5;  
  1321.     DECONVOLUTION = 39;  
  1322.     DROPOUT = 6;  
  1323.     DUMMY_DATA = 32;  
  1324.     EUCLIDEAN_LOSS = 7;  
  1325.     ELTWISE = 25;  
  1326.     EXP = 38;  
  1327.     FLATTEN = 8;  
  1328.     HDF5_DATA = 9;  
  1329.     HDF5_OUTPUT = 10;  
  1330.     HINGE_LOSS = 28;  
  1331.     IM2COL = 11;  
  1332.     IMAGE_DATA = 12;  
  1333.     INFOGAIN_LOSS = 13;  
  1334.     INNER_PRODUCT = 14;  
  1335.     LRN = 15;  
  1336.     MEMORY_DATA = 29;  
  1337.     MULTINOMIAL_LOGISTIC_LOSS = 16;  
  1338.     MVN = 34;  
  1339.     POOLING = 17;  
  1340.     POWER = 26;  
  1341.     RELU = 18;  
  1342.     SIGMOID = 19;  
  1343.     SIGMOID_CROSS_ENTROPY_LOSS = 27;  
  1344.     SILENCE = 36;  
  1345.     SOFTMAX = 20;  
  1346.     SOFTMAX_LOSS = 21;  
  1347.     SPLIT = 22;  
  1348.     SLICE = 33;  
  1349.     TANH = 23;  
  1350.     WINDOW_DATA = 24;  
  1351.     THRESHOLD = 31;  
  1352.   }  
  1353.   optional LayerType type = 5;  
  1354.   repeated BlobProto blobs = 6;  
  1355.   repeated string param = 1001;  
  1356.   repeated DimCheckMode blob_share_mode = 1002;  
  1357.   enum DimCheckMode {  
  1358.     STRICT = 0;  
  1359.     PERMISSIVE = 1;  
  1360.   }  
  1361.   repeated float blobs_lr = 7;  
  1362.   repeated float weight_decay = 8;  
  1363.   repeated float loss_weight = 35;  
  1364.   optional AccuracyParameter accuracy_param = 27;  
  1365.   optional ArgMaxParameter argmax_param = 23;  
  1366.   optional ConcatParameter concat_param = 9;  
  1367.   optional ContrastiveLossParameter contrastive_loss_param = 40;  
  1368.   optional ConvolutionParameter convolution_param = 10;  
  1369.   optional DataParameter data_param = 11;  
  1370.   optional DropoutParameter dropout_param = 12;  
  1371.   optional DummyDataParameter dummy_data_param = 26;  
  1372.   optional EltwiseParameter eltwise_param = 24;  
  1373.   optional ExpParameter exp_param = 41;  
  1374.   optional HDF5DataParameter hdf5_data_param = 13;  
  1375.   optional HDF5OutputParameter hdf5_output_param = 14;  
  1376.   optional HingeLossParameter hinge_loss_param = 29;  
  1377.   optional ImageDataParameter image_data_param = 15;  
  1378.   optional InfogainLossParameter infogain_loss_param = 16;  
  1379.   optional InnerProductParameter inner_product_param = 17;  
  1380.   optional LRNParameter lrn_param = 18;  
  1381.   optional MemoryDataParameter memory_data_param = 22;  
  1382.   optional MVNParameter mvn_param = 34;  
  1383.   optional PoolingParameter pooling_param = 19;  
  1384.   optional PowerParameter power_param = 21;  
  1385.   optional ReLUParameter relu_param = 30;  
  1386.   optional SigmoidParameter sigmoid_param = 38;  
  1387.   optional SoftmaxParameter softmax_param = 39;  
  1388.   optional SliceParameter slice_param = 31;  
  1389.   optional TanHParameter tanh_param = 37;  
  1390.   optional ThresholdParameter threshold_param = 25;  
  1391.   optional WindowDataParameter window_data_param = 20;  
  1392.   optional TransformationParameter transform_param = 36;  
  1393.   optional LossParameter loss_param = 42;  
  1394.   optional V0LayerParameter layer = 1;  
  1395. }  
  1396.   
  1397. // DEPRECATED: V0LayerParameter is the old way of specifying layer parameters  
  1398. // in Caffe.  We keep this message type around for legacy support.  
  1399. // 旧版本:V0LayerParameter version-0版  
  1400. message V0LayerParameter {  
  1401.   optional string name = 1; // the layer name  
  1402.   optional string type = 2; // the string to specify the layer type  
  1403.   
  1404.   // Parameters to specify layers with inner products.  
  1405.   optional uint32 num_output = 3; // The number of outputs for the layer  
  1406.   optional bool biasterm = 4 [default = true]; // whether to have bias terms  
  1407.   optional FillerParameter weight_filler = 5; // The filler for the weight  
  1408.   optional FillerParameter bias_filler = 6; // The filler for the bias  
  1409.   
  1410.   optional uint32 pad = 7 [default = 0]; // The padding size  
  1411.   optional uint32 kernelsize = 8; // The kernel size  
  1412.   optional uint32 group = 9 [default = 1]; // The group size for group conv  
  1413.   optional uint32 stride = 10 [default = 1]; // The stride  
  1414.   enum PoolMethod {  
  1415.     MAX = 0;  
  1416.     AVE = 1;  
  1417.     STOCHASTIC = 2;  
  1418.   }  
  1419.   optional PoolMethod pool = 11 [default = MAX]; // The pooling method  
  1420.   optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio  
  1421.   
  1422.   optional uint32 local_size = 13 [default = 5]; // for local response norm  
  1423.   optional float alpha = 14 [default = 1.]; // for local response norm  
  1424.   optional float beta = 15 [default = 0.75]; // for local response norm  
  1425.   optional float k = 22 [default = 1.];  
  1426.   
  1427.   // For data layers, specify the data source  
  1428.   optional string source = 16;  
  1429.   // For data pre-processing, we can do simple scaling and subtracting the  
  1430.   // data mean, if provided. Note that the mean subtraction is always carried  
  1431.   // out before scaling.  
  1432.   optional float scale = 17 [default = 1];  
  1433.   optional string meanfile = 18;  
  1434.   // For data layers, specify the batch size.  
  1435.   optional uint32 batchsize = 19;  
  1436.   // For data layers, specify if we would like to randomly crop an image.  
  1437.   optional uint32 cropsize = 20 [default = 0];  
  1438.   // For data layers, specify if we want to randomly mirror data.  
  1439.   optional bool mirror = 21 [default = false];  
  1440.   
  1441.   // The blobs containing the numeric parameters of the layer  
  1442.   repeated BlobProto blobs = 50;  
  1443.   // The ratio that is multiplied on the global learning rate. If you want to  
  1444.   // set the learning ratio for one blob, you need to set it for all blobs.  
  1445.   repeated float blobs_lr = 51;  
  1446.   // The weight decay that is multiplied on the global weight decay.  
  1447.   repeated float weight_decay = 52;  
  1448.   
  1449.   // The rand_skip variable is for the data layer to skip a few data points  
  1450.   // to avoid all asynchronous sgd clients to start at the same point. The skip  
  1451.   // point would be set as rand_skip * rand(0,1). Note that rand_skip should not  
  1452.   // be larger than the number of keys in the database.  
  1453.   optional uint32 rand_skip = 53 [default = 0];  
  1454.   
  1455.   // Fields related to detection (det_*)  
  1456.   // foreground (object) overlap threshold  
  1457.   optional float det_fg_threshold = 54 [default = 0.5];  
  1458.   // background (non-object) overlap threshold  
  1459.   optional float det_bg_threshold = 55 [default = 0.5];  
  1460.   // Fraction of batch that should be foreground objects  
  1461.   optional float det_fg_fraction = 56 [default = 0.25];  
  1462.   
  1463.   // optional bool OBSOLETE_can_clobber = 57 [default = true];  
  1464.   
  1465.   // Amount of contextual padding to add around a window  
  1466.   // (used only by the window_data_layer)  
  1467.   optional uint32 det_context_pad = 58 [default = 0];  
  1468.   
  1469.   // Mode for cropping out a detection window  
  1470.   // warp: cropped window is warped to a fixed size and aspect ratio  
  1471.   // square: the tightest square around the window is cropped  
  1472.   optional string det_crop_mode = 59 [default = "warp"];  
  1473.   
  1474.   // For ReshapeLayer, one needs to specify the new dimensions.  
  1475.   optional int32 new_num = 60 [default = 0];  
  1476.   optional int32 new_channels = 61 [default = 0];  
  1477.   optional int32 new_height = 62 [default = 0];  
  1478.   optional int32 new_width = 63 [default = 0];  
  1479.   
  1480.   // Whether or not ImageLayer should shuffle the list of files at every epoch.  
  1481.   // It will also resize images if new_height or new_width are not zero.  
  1482.   optional bool shuffle_images = 64 [default = false];  
  1483.   
  1484.   // For ConcatLayer, one needs to specify the dimension for concatenation, and  
  1485.   // the other dimensions must be the same for all the bottom blobs.  
  1486.   // By default it will concatenate blobs along the channels dimension.  
  1487.   optional uint32 concat_dim = 65 [default = 1];  
  1488.   
  1489.   optional HDF5OutputParameter hdf5_output_param = 1001;  
  1490. }  
  1491. //PReLUParameter,源于论文  
  1492. message PReLUParameter {  
  1493.   // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers:  
  1494.   // Surpassing Human-Level Performance on ImageNet Classification, 2015.  
  1495.   
  1496.   // Initial value of a_i. Default is a_i=0.25 for all i.  
  1497.   optional FillerParameter filler = 1;  
  1498.   // Whether or not slope paramters are shared across channels.  
  1499.   optional bool channel_shared = 2 [default = false];  

0 0
原创粉丝点击