caffe 学习笔记之caffe.proto注释

caffe.proto注释转自caffe.proto注释上并加以修改

syntax = "proto2";

package caffe;
//  repeated  required optional 
//  可重复,类似数组     必要的      可选的
// Specifies the shape (dimensions) of a Blob.
// n*c*w*h
message BlobShape {
  repeated int64 dim = 1 [packed = true];
}

message BlobProto {
  optional BlobShape shape = 7; //下文中替代4D描述符的结构
  repeated float data = 5 [packed = true];
  repeated float diff = 6 [packed = true];
  repeated double double_data = 8 [packed = true];
  repeated double double_diff = 9 [packed = true];

  // 4D dimensions -- deprecated.  Use "shape" instead.

  // 4维的描述方式舍弃掉,改用"BlobShape"结构替代
  optional int32 num = 1 [default = 0];
  optional int32 channels = 2 [default = 0];
  optional int32 height = 3 [default = 0];
  optional int32 width = 4 [default = 0];
}

// The BlobProtoVector is simply a way to pass multiple blobproto instances
// around.
message BlobProtoVector {
  repeated BlobProto blobs = 1;
}

//图像数据结构
message Datum {
  optional int32 channels = 1;
  optional int32 height = 2;
  optional int32 width = 3;
  // the actual image data, in bytes
  //实际上以字节存储图像内容
  optional bytes data = 4;
  optional int32 label = 5;
  // Optionally, the datum could also hold float data.
  repeated float float_data = 6;
  // If true data contains an encoded image that need to be decoded
  optional bool encoded = 7 [default = false];
}

message FillerParameter {
  // The filler type.
  optional string type = 1 [default = 'constant'];
  optional float value = 2 [default = 0]; // the value in constant filler
  optional float min = 3 [default = 0]; // the min value in uniform filler
  optional float max = 4 [default = 1]; // the max value in uniform filler
  optional float mean = 5 [default = 0]; // the mean value in Gaussian filler
  optional float std = 6 [default = 1]; // the std value in Gaussian filler
  // The expected number of non-zero output weights for a given input in
  // Gaussian filler -- the default -1 means don't perform sparsification.
  //非零的输出值以高斯滤波系数值的方式填充
  //默认值为-1,不进行稀疏化
  optional int32 sparse = 7 [default = -1];
  // Normalize the filler variance by fan_in, fan_out, or their average.
  // Applies to 'xavier' and 'msra' fillers.

  //Protocol Buffer中的枚举和C++中类似
  enum VarianceNorm {
    FAN_IN = 0;
    FAN_OUT = 1;
    AVERAGE = 2;
  }
  optional VarianceNorm variance_norm = 8 [default = FAN_IN];
}

//网络参数
message NetParameter {
  optional string name = 1; // consider giving the network a name
  // The input blobs to the network.
  repeated string input = 3;
  // The shape of the input blobs.
  repeated BlobShape input_shape = 8;

  // 4D input dimensions -- deprecated.  Use "shape" instead.
  // If specified, for each input blob there should be four
  // values specifying thenum, channels, height and width of the input blob.
  // Thus, there should be a total of (4 * #input) numbers.
  repeated int32 input_dim = 4;

  // Whether the network will force every layer to carry out backward operation.
  // If set False, then whether to carry out backward is determined
  // automatically according to the net structure and learning rates.
  //网络是否会迫使每一层都进行反向操作。
  //如果设置为False,则根据网络结构和学习速率自动确定是否执行反向传播操作。
  optional bool force_backward = 5 [default = false];
  // The current "state" of the network, including the phase, level, and stage.
  //当前的网络状态有phase,level,stage三种状态。
  // Some layers may be included/excluded depending on this state and the states
  // specified in the layers' include and exclude fields.
  //根据此状态和图层的包含和非包含字段中指定的状态,可以包括/排除某些网络层。
  optional NetState state = 6;

  // Print debugging information about results while running Net::Forward,
  // Net::Backward, and Net::Update.
  //当运行前向网络,后向网络,更新网络的时候打印调试信息,默认不打印
  optional bool debug_info = 7 [default = false];

  // The layers that make up the net.  Each of their configurations, including
  // connectivity and behavior, is specified as a LayerParameter.
  //很多层就构成了网络模型.连接和行为等配置参数构成了层参数.最后打印出来
  repeated LayerParameter layer = 100;  // ID 100 so layers are printed last.

  // DEPRECATED: use 'layer' instead.
  //此后改用'layer'结构
  repeated V1LayerParameter layers = 2;
}

// NOTE
// Update the next available ID when you add a new SolverParameter field.
//注意
//当你添加新的求解器参数对象时,更新了新的可用ID ,为 ID 41  type
//
// SolverParameter next available ID: 41 (last added: type)
//求解器参数
message SolverParameter {
  //////////////////////////////////////////////////////////////////////////////
  // Specifying the train and test networks
  //
  // Exactly one train net must be specified using one of the following fields:
  //     train_net_param, train_net, net_param, net
  // One or moretest nets may be specified using any of the following fields:
  //    test_net_param, test_net, net_param, net
  // If more than one test net field is specified (e.g., both net and
  // test_net are specified), they will be evaluated in the field order given
  // above: (1) test_net_param, (2) test_net, (3) net_param/net.
  //如果指定了多个测试网络字段(例如,指定了net和test_net),则将以上面给出的字段顺序对它们求值:
  //(1)test_net_param,(2)test_net,(3)net_param / net。
  // A test_iter must be specified for each test_net.
  // 必须为每个test_net 指定 test_iter
  // A test_level and/or a test_stage may also be specified for each test_net.
  // 还可以为每个test_net指定test_level和/或test_stage
  //////////////////////////////////////////////////////////////////////////////

  // Proto filename for the train net, possibly combined with one or more
  // test nets.
  //对于训练网络的原型文件名可能由一个或者多个训练网络组成。
  optional string net = 24;
  // Inline train net param, possibly combined with one or more test nets.
  // 内联训练网络参数可能含有一个或者多个测试网络
  optional NetParameter net_param = 25;

  optional string train_net = 1; // Proto filename for the train net.
  repeated string test_net = 2; // Proto filenames for the test nets.
  optional NetParameter train_net_param = 21; // Inline train net params.
  repeated NetParameter test_net_param = 22; // Inline test net params.

  // The states for the train/test nets. Must be unspecified or
  // specified once per net.
  //要么确定,要么不确定,一旦确定,要么全是测试网络要么全是训练网络
  //
  // By default, all states will have solver = true;
  // train_state will have phase = TRAIN,
  // and all test_state's will have phase = TEST.
  // Other defaults are set according to the NetState defaults.
  //默认的,所有求解器的状态为真.训练网络 phase = TRAIN,测试网络phase = TEST,
  //其他情况有网络状态的默认值决定

  optional NetState train_state = 26;
  repeated NetState test_state = 27;

  // The number of iterations for each test net.
  repeated int32 test_iter = 3;

  // The number of iterations between two testing phases.
  // 两个测试阶段之间的迭代次数。
  optional int32 test_interval = 4 [default = 0];
  optional bool test_compute_loss = 19 [default = false];
  // If true, run an initial test pass before the first iteration,
  // ensuring memory availability and printing the starting value of the loss.
  // 若为真,在执行第一次迭代之前,先得运行初始化测试通过来确保有足够存储资源和打印初始值的loss信息
  optional bool test_initialization = 32 [default = true];
  optional float base_lr = 5; // The base learning rate //基准学习率
  // the number of iterations between displaying info. If display = 0, no info
  // will be displayed.
  // 显示迭代之间显示信息,如果display = 0,则没有信息显示
  optional int32 display = 6;
  // Display the loss averaged over the last average_loss iterations
  // 显示上次average_loss迭代的平均损失
  optional int32 average_loss = 33 [default = 1];
  optional int32 max_iter = 7; // the maximum number of iterations
  // accumulate gradients over `iter_size` x `batch_size` instances
  optional int32 iter_size = 36 [default = 1];

  // The learning rate decay policy. The currently implemented learning rate
  // policies are as follows:
  //    - fixed: always returnbase_lr.
  //    - step: returnbase_lr *gamma ^ (floor(iter / step))
  //    - exp: returnbase_lr *gamma ^ iter
  //    - inv: returnbase_lr * (1 +gamma * iter) ^ (- power)
  //    - multistep: similar to step but it allows non uniform steps defined by
  //      stepvalue
  //    - poly: the effective learning rate follows a polynomial decay, to be
  //      zero by the max_iter. returnbase_lr (1 -iter/max_iter) ^ (power)
  //    - sigmoid: the effective learning rate follows a sigmod decay
  //      return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize))))
  //
  // where base_lr, max_iter, gamma, step, stepvalue and power are defined
  // in the solver parameter protocol buffer, and iter is the current iteration.
  optional string lr_policy = 8;
  optional float gamma = 9; // The parameter to compute the learning rate.
  optional float power = 10; // The parameter to compute the learning rate.
  optional float momentum = 11; // The momentum value. //动量值
  optional float weight_decay = 12; // The weight decay. //权重衰减
  // regularization types supported: L1 and L2
  // controlled by weight_decay
  //正则化方式支持:L1 和 L2
  //由权值衰减变量控制
  optional string regularization_type = 29 [default = "L2"]; //默认正则化方式为L2
  // the stepsize for learning rate policy "step"
  optional int32 stepsize = 13;
  // the stepsize for learning rate policy "multistep"
  repeated int32 stepvalue = 34;

  // Set clip_gradients to >= 0 to clip parameter gradients to that L2 norm,
  // whenever their actual L2 norm is larger.
  // 设置clip_gradients大于零,只要它比实际的L2范数大,那么它就等于L2范数 
  optional float clip_gradients = 35 [default = -1];

  optional int32 snapshot = 14 [default = 0]; // The snapshot interval  //snapshot:快照
  optional string snapshot_prefix = 15; // The prefix for the snapshot. //prefix:字首
  // whether to snapshot diff in the results or not. Snapshotting diff will help
  // debugging but the final protocol buffer size will be much larger.
  // 无论快照在结果中有无差值,快照的差值将会有助于调试,但是最终的protocol buffer的尺寸会大很多
  //
  optional bool snapshot_diff = 16 [default = false];
  enum SnapshotFormat {
    HDF5 = 0;
    BINARYPROTO = 1;
  }
  optional SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
  // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default.
  enum SolverMode {
    CPU = 0;
    GPU = 1;
  }
  optional SolverMode solver_mode = 17 [default = GPU];
  // the device_id will that be used in GPU mode. Use device_id = 0 in default.
  optional int32 device_id = 18 [default = 0];
  // If non-negative, the seed with which the Solver will initialize the Caffe
  // random number generator -- useful for reproducible results. Otherwise,
  // (and by default) initialize using a seed derived from the system clock.
  optional int64 random_seed = 20 [default = -1];

  // type of the solver
  //求解器的类型 默认类型为SGD
  optional string type = 40 [default = "SGD"]; //string 类型

  // numerical stability for RMSProp, AdaGrad and AdaDelta and Adam
  // 对于RMSProp, AdaGrad and AdaDelta and Adam的数值稳定性默认阈值为 1e-8
  optional float delta = 31 [default = 1e-8];
  // parameters for the Adam solver
  // 自适应动量求解器的衰减的默认取值为0.999
  optional float momentum2 = 39 [default = 0.999];

  // RMSProp decay value
  // RMSProp的衰减值
  // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t)
  // 均方差的迭代求解关系
  // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t)
  optional float rms_decay = 38;

  // If true, print information about the state of the net that may help with
  // debugging learning problems.
  // 是否打印调试信息,默认设置为否
  optional bool debug_info = 23 [default = false];

  // If false, don't save a snapshot after training finishes.
  //如何设置为否,则不保存每次训练结束后的快照
  optional bool snapshot_after_train = 28 [default = true];

  // DEPRECATED: old solver enum types, use string instead
  //舍弃旧的求解器枚举类型,使用string代替
  enum SolverType {
    SGD = 0;
    NESTEROV = 1;
    ADAGRAD = 2;
    RMSPROP = 3;
    ADADELTA = 4;
    ADAM = 5;
  }
  // DEPRECATED: use type instead of solver_type
  // 舍弃solver_type, 改用 type
  optional SolverType solver_type = 30 [default = SGD];
}

// A message that stores the solver snapshots
message SolverState {
  optional int32 iter = 1; // The current iteration //当前迭代
  optional string learned_net = 2; // The file that stores the learned net. //保存学习网络的文件
  repeated BlobProto history = 3; // The history for sgd solvers //sgd求解器的历史记录
  optional int32 current_step = 4 [default = 0]; // The current step for learning rate //当前学习率的步进
}

//状态枚举:训练或者测试
enum Phase { 
   TRAIN = 0;
   TEST = 1;
}

//网络状态
message NetState {
  optional Phase phase = 1 [default = TEST];
  optional int32 level = 2 [default = 0];
  repeated string stage = 3;
}

//Rule网络状态
message NetStateRule {
  // Set phase to require the NetState have a particular phase (TRAIN or TEST)
  // to meet this rule.
  optional Phase phase = 1;

  // Set the minimum and/or maximum levels in which the layer should be used.
  // Leave undefined to meet the rule regardless of level.
  //设置Rule层需使用的最大与/或最小层,其他未定义的层需满足rule规则。
  optional int32 min_level = 2;
  optional int32 max_level = 3;

  // Customizable sets of stages to include or exclude.
  //包含或排除用户自定义集的状态
  // The net must have ALL of the specified stages and NONE of the specified
  // "not_stage"s to meet the rule.
  //网络必须含有所有具体的状态,使用多层网络Rlue用于连接特定状态
  // (Use multiple NetStateRules to specify conjunctions of stages.)
  repeated string stage = 4;
  repeated string not_stage = 5;
}

// Specifies training parameters (multipliers on global learning constants,
// and the name and other settings used for weight sharing).
// 指定训练参数(多层网络的全局学习常数,以及用于权重分配的名称和其他设置)。
message ParamSpec {
  // The names of the parameter blobs -- useful for sharing parameters among
  // layers, but never required otherwise.  To share a parameter between two
  // layers, give it a (non-empty) name.
  // blobs参数的名称-用于在图层之间共享参数,但从不需要。为了共享一个参数给两层网络,给它一个名字
  optional string name = 1;

  // Whether to require shared weights to have the same shape, or just the same
  // count -- defaults to STRICT if unspecified.
  // 无论是为了相同的shape而共享权值,或者仅仅只是计数。默认情况下如果未指定则为STRICT(限制)
  // 
  optional DimCheckMode share_mode = 2;
  enum DimCheckMode {
    // STRICT (default) requires thatnum, channels, height, width each match.
    //STRICT 限制 (默认)num, channels, height, width为shape的四个参数,对应一一匹配
    STRICT = 0;
    // PERMISSIVE requires only the count (num*channels*height*width) to match.
    // PERMISSIVE 允许 仅需要num*channels*height*width的数相同即可
    PERMISSIVE = 1;
  }

  // The multiplier on the global learning rate for this parameter.
  //该参数在全局上的学习率的乘数
  optional float lr_mult = 3 [default = 1.0];

  // The multiplier on the global weight decay for this parameter.
  // 该参数在全局上的权值衰减的乘数
  optional float decay_mult = 4 [default = 1.0];
}

// NOTE
// Update the next available ID when you add a new LayerParameter field.
//注意
//当你增加新的网络参数字段时,更新新的可用ID
// LayerParameter next available layer-specific ID: 143 (last added: scale_param)
//   新的可用字段号为143
message LayerParameter {
  optional string name = 1; // the layer name
  optional string type = 2; // the layer type
  repeated string bottom = 3; // the name of each bottom blob
  repeated string top = 4; // the name of each top blob

  // The train / test phase for computation.
  optional Phase phase = 10;

  // The amount of weight to assign each top blob in the objective.
  // Each layer assigns a default value, usually of either 0 or 1,
  // to each top blob.
  // 在目标中分配每个顶部blob的权重量。每个图层为每个顶部blob分配一个默认值,通常为0或1。
  repeated float loss_weight = 5;

  // Specifies training parameters (multipliers on global learning constants,
  // and the name and other settings used for weight sharing).
  // 指定训练参数(全局学习常数的乘数,以及用于权值共享的名称和其他设置)。
  repeated ParamSpec param = 6;

  // The blobs containing the numeric parameters of the layer.
  // blob包含层的数值参数。
  repeated BlobProto blobs = 7;

  // Specifies on which bottoms the backpropagation should be skipped.
  //反向传播中指定应该跳过哪些bottoms
  // The size must be either 0 or equal to the number of bottoms.
  // 大小为0或者等于bottoms的个数
  repeated bool propagate_down = 11;

  // Rules controlling whether and when a layer is included in the network,
  // based on the current NetState.  You may specify a non-zero number of rules
  // to include OR exclude, but not both.  If no include or exclude rules are
  // specified, the layer is always included.  If the current NetState meets
  // ANY (i.e., one or more) of the specified rules, the layer is
  // included/excluded.
  // Rules 基于当前的网络状态控制该层是否包含在网络中,您可以指定非零数量的规则以包括或排除,但不能同时包含两者。
  // 如果未指定包含或排除规则,则始终包括该层。如果当前网络状态满足指定规则中的任意(即一个或多个),则包括/排除该层。
  repeated NetStateRule include = 8;
  repeated NetStateRule exclude = 9;

  // Parameters for data pre-processing.
  // 数据预处理的参数
  optional TransformationParameter transform_param = 100;

  // Parameters shared by loss layers.
  // 损耗层共享的参数。
  optional LossParameter loss_param = 101;

  // Layer type-specific parameters.
  // 层的各种具体类型的参数
  // Note: certain layers may have more than one computational engine
  // for their implementation. These layers include an Engine type and
  // engine parameter for selecting the implementation.
  // The default for the engine is set by the ENGINE switch at compile-time.
  // 注意:某些图层可能有多个计算引擎用于实现。
  // 这些层包括用于选择实现的引擎类型和引擎参数。
  // 引擎的默认值由编译时的ENGINE开关设置。
  optional AccuracyParameter accuracy_param = 102;//准确率
  optional ArgMaxParameter argmax_param = 103;//极大值
  optional BatchNormParameter batch_norm_param = 139;//块归一化
  optional BiasParameter bias_param = 141;//偏置
  optional ConcatParameter concat_param = 104;//连续
  optional ContrastiveLossParameter contrastive_loss_param = 105;//对比损失
  optional ConvolutionParameter convolution_param = 106;//卷积
  optional DataParameter data_param = 107;//数据
  optional DropoutParameter dropout_param = 108;//dropout
  optional DummyDataParameter dummy_data_param = 109;// 填充数据
  optional EltwiseParameter eltwise_param = 110;//eltwise
  optional ELUParameter elu_param = 140;//elu
  optional EmbedParameter embed_param = 137;//嵌入
  optional ExpParameter exp_param = 111;
  optional FlattenParameter flatten_param = 135;
  optional HDF5DataParameter hdf5_data_param = 112;//hdf5 输入参数
  optional HDF5OutputParameter hdf5_output_param = 113;//hdf5 数据输出参数
  optional HingeLossParameter hinge_loss_param = 114;//合并损失
  optional ImageDataParameter image_data_param = 115;//图像数据
  optional InfogainLossParameter infogain_loss_param = 116;//信息获取?infogain
  optional InnerProductParameter inner_product_param = 117;//全连接层参数
  optional LogParameter log_param = 134;//对数参数
  optional LRNParameter lrn_param = 118;//局部响应归一化参数
  optional MemoryDataParameter memory_data_param = 119;//内存数据参数
  optional MVNParameter mvn_param = 120;//mvn?
  optional PoolingParameter pooling_param = 121;池化参数
  optional PowerParameter power_param = 122;//能量参数
  optional PReLUParameter prelu_param = 131;//预Relu参数
  optional PythonParameter python_param = 130;//python参数
  optional ReductionParameter reduction_param = 136;//减少参数
  optional ReLUParameter relu_param = 123;//relu
  optional ReshapeParameter reshape_param = 133;//更改形状
  optional ROIPoolingParameter roi_pooling_param = 8266711;//ROI池化参数
  optional ScaleParameter scale_param = 142;//尺度化参数
  optional SigmoidParameter sigmoid_param = 124;//simgmoid参数
  optional SmoothL1LossParameter smooth_l1_loss_param = 8266712;//平滑l1损失参数
  optional SoftmaxParameter softmax_param = 125;//softmax参数
  optional SPPParameter spp_param = 132;//SPP参数
  optional SliceParameter slice_param = 126;//切片参数
  optional TanHParameter tanh_param = 127;//反正切参数
  optional ThresholdParameter threshold_param = 128;//阈值参数
  optional TileParameter tile_param = 138;tile参数
  optional WindowDataParameter window_data_param = 129;//window数据参数
}

// Message that stores parameters used to apply transformation
// to the data layer's data
// 存储将数据转换应用到数据层的消息结构
message TransformationParameter {
  // For data pre-processing, we can do simple scaling and subtracting the
  // data mean, if provided. Note that the mean subtraction is always carried
  // out before scaling.
  // 如果使用数据预处理,我们可以做一些简单的尺度化和对数据均值的减法。
  // 注意,减法操作在尺度化操作之前
  optional float scale = 1 [default = 1];
  // Specify if we want to randomly mirror data.
  optional bool mirror = 2 [default = false];
  // Specify if we would like to randomly crop an image.
  optional uint32 crop_size = 3 [default = 0];
  // mean_file and mean_value cannot be specified at the same time
  // 不能同时制定mean_file 和 mean_value
  optional string mean_file = 4;
  // if specified can be repeated once (would substract it from all the channels)
  // or can be repeated the same number of times as channels
  // (would subtract them from the corresponding channel)
   // 可有且仅可有一次(从所有通道中减去它)
   // 或者每个通道单独减去它们

  repeated float mean_value = 5;
  // Force the decoded image to have 3 color channels.
  // 强制解码成三通道颜色
  optional bool force_color = 6 [default = false];
  // Force the decoded image to have 1 color channels.
  // 强制解码成单通道颜色
  optional bool force_gray = 7 [default = false];
}

// Message that stores parameters shared by loss layers
// 存储有损耗层共享的消息结构
message LossParameter {
  // If specified, ignore instances with the given label.
  // 如果指定,忽略给定标签的实例
  optional int32 ignore_label = 1;
  // How to normalize the loss for loss layers that aggregate across batches,
  // spatial dimensions, or other dimensions.  Currently only implemented in
  // SoftmaxWithLoss layer.
  // 如何归一化在不同批次之间聚合的损失层的损失,空间尺寸或其他尺寸。
  // 目前仅实现了SoftmaxWithLoss层
  enum NormalizationMode {
    // Divide by the number of examples in the batch times spatial dimensions.
    // Outputs that receive the ignore label will NOT be ignored in computing
    // the normalization factor.
    // 除以例子中批次时域尺寸的数目
    // 接受的输出中忽略的标签将会考虑在计算归一化因子的过程中
    FULL = 0;
    // Divide by the total number of output locations that do not take the
    // ignore_label.  If ignore_label is not set, this behaves like FULL.
    // 除以未采用ignore_label的输出位置的总数。 如果未设置ignore_label,则其行为类似于FULL。
    VALID = 1;
    // Divide by the batch size.
    // 除以批尺寸
    BATCH_SIZE = 2;
    // Do not normalize the loss.
    // 不归一化
    NONE = 3;
  }
  optional NormalizationMode normalization = 3 [default = VALID];
  // Deprecated.  Ignored if normalization is specified.  If normalization
  // is not specified, then setting this to false will be equivalent to
  // normalization = BATCH_SIZE to be consistent with previous behavior.
  // 已弃用。 如果指定了归一化,则忽略。 如果未指定规范化,则将其设置为false,
  // 将等同于规范化= BATCH_SIZE,以与以前的行为一致。
  optional bool normalize = 2;
}

// Messages that store parameters used by individual layer types follow, in
// alphabetical order.

message AccuracyParameter {
  // When computing accuracy, count as correct by comparing the true label to
  // the top k scoring classes.  By default, only compare to the top scoring
  // class (i.e. argmax).
  // 当计算准确性时,通过将真实标签与前k个评分类进行比较来计算为正确。
  // 默认情况下,只比较顶级评分类(即argmax)。
  optional uint32 top_k = 1 [default = 1];

  // The "label" axis of the prediction blob, whose argmax corresponds to the
  // predicted label -- may be negative to index from the end (e.g., -1 for the
  // last axis).  For example, if axis == 1 and the predictions are
  // (N x C x H x W), the label blob is expected to contain N*H*W ground truth
  // labels with integer values in {0, 1, ..., C-1}.
  // 预测blob的“标签”轴(其argmax对应于预测标签)可以从末端开始索引(例如,对于最后一个轴为-1)。
  // 例如,如果axis == 1并且预测是(N×C×H×W),则期望标签blob包含具有{0,1,...,N}中的整数值}。
  optional int32 axis = 2 [default = 1];

  // If specified, ignore instances with the given label.
  // 如果指定,忽略给定标签的实例
  optional int32 ignore_label = 3;
}

message ArgMaxParameter {
  // If true produce pairs (argmax, maxval)
  // 如果为真,产生 (argmax, maxval)数据对,默认为假
  optional bool out_max_val = 1 [default = false];
  optional uint32 top_k = 2 [default = 1];
  // The axis along which to maximise -- may be negative to index from the
  // end (e.g., -1 for the last axis).
  // 沿其最大化的轴可以对从末端开始的索引为负(例如,对于最后一个轴为-1)。
  // By default ArgMaxLayer maximizes over the flattened trailing dimensions
  // for each index of the first / num dimension.
  // 默认情况下,ArgMaxLayer最大化第一个/num维度的每个索引的摊平尾部维度。
  optional int32 axis = 3;
}

message ConcatParameter {
  // The axis along which to concatenate -- may be negative to index from the
  // end (e.g., -1 for the last axis).  Other axes must have the
  // same dimension for all the bottom blobs.
  // By default, ConcatLayer concatenates blobs along the "channels" axis (1).
  // 沿着其连接的轴 - 可以从末尾开始索引(例如,对于最后一个轴为-1)。 其他轴必须有
  // 相同尺寸的所有底部斑点。
  // 默认情况下,ConcatLayer沿着“通道”轴(1)连接blob。
  optional int32 axis = 2 [default = 1];

  // DEPRECATED: alias for "axis" -- does not support negative indexing.
  // DEPRECATED:“axis”的别名 - 不支持负索引。
  optional uint32 concat_dim = 1 [default = 1];
}

message BatchNormParameter {
  // If false, accumulate global mean/variance values via a moving average. If
  // true, use those accumulated values instead of computing mean/variance
  // across the batch.
  // 如果为假,则通过移动平均值累积全局均值/方差值。
  // 如果为真,请使用这些累计值,而不是计算整个批次的均值/方差。
  optional bool use_global_stats = 1;
  // How much does the moving average decay each iteration?
  //每次迭代移动平均值衰减有多少?
  optional float moving_average_fraction = 2 [default = .999];
  // Small value to add to the variance estimate so that we don't divide by
  // zero.
  // 防止除0
  optional float eps = 3 [default = 1e-5];
}

message BiasParameter {
  // The first axis of bottom[0] (the first input Blob) along which to apply
  // bottom[1] (the second input Blob).  May be negative to index from the end
  // (e.g., -1 for the last axis).
  //
  // 底部[0]的第一个轴(第一个输入Blob),沿着它应用底部[1](第二个输入Blob)。
  // 可以从末尾开始索引(例如,对于最后一个轴为-1)。
  // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
  // top[0] will have the same shape, and bottom[1] may have any of the
  // following shapes (for the given value of axis):
  // 例如,如果底部[0]是具有形状100x3x40x60的4D,则为输出
  // 顶部[0]将具有相同的形状,底部[1]可具有任何的
  // 以下形状(对于给定的轴值):
  //    (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
  //    (axis == 1 == -3)          3;     3x40;     3x40x60
  //    (axis == 2 == -2)                   40;       40x60
  //    (axis == 3 == -1)                                60
  // Furthermore, bottom[1] may have the empty shape (regardless of the value of
  // "axis") -- a scalar bias.
  // 此外,底部[1]可以具有空形状(不管“轴”的值) - 标量偏差。
  optional int32 axis = 1 [default = 1];

  // (num_axes is ignored unless just one bottom is given and the bias is
  // a learned parameter of the layer.  Otherwise, num_axes is determined by the
  // number of axes by the second bottom.)
  // (忽略num_axes,除非给定一个底部,偏差是层的学习参数,否则num_axes由第二个底部的轴数确定)。
  // The number of axes of the input (bottom[0]) covered by the bias
  // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
  // Set num_axes := 0, to add a zero-axis Blob: a scalar.
  // 由偏置参数覆盖的输入(底部[0])的轴数,或从“轴”开始覆盖底部[0]的所有轴的-1。
  // 设置num_axes:= 0,以添加零轴Blob:标量。
  optional int32 num_axes = 2 [default = 1];

  // (filler is ignored unless just one bottom is given and the bias is
  // a learned parameter of the layer.)
  // The initialization for the learned bias parameter.
  // Default is the zero (0) initialization, resulting in the BiasLayer
  // initially performing the identity operation.
  // (填充被忽略,除非只给出一个底部,并且偏置是层的学习参数)。
  // 学习的偏置参数的初始化。
  // 默认是零(0)初始化,导致偏置层初始化执行识别操作。
  optional FillerParameter filler = 3;
}
message ContrastiveLossParameter {
  // margin for dissimilar pair
  optional float margin = 1 [default = 1.0];
  // The first implementation of this cost did not exactly match the cost of
  // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2.
  // legacy_version = false (the default) uses (margin - d)^2 as proposed in the
  // Hadsell paper. New models should probably use this version.
  // legacy_version = true uses (margin - d^2). This is kept to support /
  // reproduce existing models and results
  // 这个成本的第一个实现并不完全匹配的成本 Hadsell等人2006 - 使用(margin-d ^ 2)而不是(margin-d)^ 2。
  // legacy_version = false(默认)使用(margin-d)^ 2建议的 Hadsell文中。 新模型应该可以使用这个版本。
  // legacy_version = true uses(margin - d ^ 2)。 这保持支持/ 重现现有模型和结果
  optional bool legacy_version = 2 [default = false];
}

message ConvolutionParameter {
  optional uint32 num_output = 1; // The number of outputs for the layer
  optional bool bias_term = 2 [default = true]; // whether to have bias terms:是否含有偏置

  // Pad, kernel size, and stride are all given as a single value for equal
  // dimensions in all spatial dimensions, or once per spatial dimension.
  // 填充,内核大小和步幅都被给定为在所有空间维度中相等维度的单个值,或者每个空间维度一次。
  repeated uint32 pad = 3; // The padding size; defaults to 0
  repeated uint32 kernel_size = 4; // The kernel size
  repeated uint32 stride = 6; // The stride; defaults to 1
  // Factor used to dilate the kernel, (implicitly) zero-filling the resulting
  // holes. (Kernel dilation is sometimes referred to by its use in the
  // algorithme à trous from Holschneider et al. 1987.)
  // 用于膨胀内核的因子,(隐含地)填充所产生的孔。
  //(内核膨胀有时通过其在Holschneider等人1987的算法中的使用来指代)
  repeated uint32 dilation = 18; // The dilation; defaults to 1

  // For 2D convolution only, the *_h and *_w versions may also be used to
  // specify both spatial dimensions.
  // 仅针对2D卷积,*_h and *_w version也可以用作指定的时域维度
  optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only)
  optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only)
  optional uint32 kernel_h = 11; // The kernel height (2D only)
  optional uint32 kernel_w = 12; // The kernel width (2D only)
  optional uint32 stride_h = 13; // The stride height (2D only)
  optional uint32 stride_w = 14; // The stride width (2D only)

  optional uint32 group = 5 [default = 1]; // The group size for group conv

  optional FillerParameter weight_filler = 7; // The filler for the weight
  optional FillerParameter bias_filler = 8; // The filler for the bias
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 15 [default = DEFAULT];

  // The axis to interpret as "channels" when performing convolution.
  // Preceding dimensions are treated as independent inputs;
  // succeeding dimensions are treated as "spatial".
  // With (N, C, H, W) inputs, and axis == 1 (the default), we perform
  // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for
  // groups g>1) filters across the spatial axes (H, W) of the input.
  // With (N, C, D, H, W) inputs, and axis == 1, we perform
  // N independent 3D convolutions, sliding (C/g)-channels
  // filters across the spatial axes (D, H, W) of the input.
  // 执行卷积时解释为“通道”的轴。 先前维度被视为独立输入;后续维度被视为“空间”。
  //(N,C,H,W)输入和axis == 1(默认),我们执行N个独立的2D卷积,
  // 滑动C通道(或(C / g)通道,对于组g> 1)在输入的空间轴(H,W)上进行滤波。
  // 利用(N,C,D,H,W)输入和轴== 1,我们执行N个独立的3D卷积,在输入的空间轴(D,H,W)上滑动(C / g) 。
  optional int32 axis = 16 [default = 1];

  // Whether to force use of the general ND convolution, even if a specific
  // implementation for blobs of the appropriate number of spatial dimensions
  // is available. (Currently, there is only a 2D-specific convolution
  // implementation; for input blobs with num_axes != 2, this option is
  // ignored and the ND implementation will be used.)
  // 是否强制使用一般的ND卷积,即使可用具有适当数量的空间维度的blob的特定实现。
  // (目前,只有2D特定卷积实现;对于num_axes!= 2的输入blob,此选项被忽略,将使用ND实现)。
  optional bool force_nd_im2col = 17 [default = false];
}

message DataParameter {
  enum DB {
    LEVELDB = 0;
    LMDB = 1;
  }
  // Specify the data source. //指定数据源
  optional string source = 1;
  // Specify the batch size. //指定块尺寸
  optional uint32 batch_size = 4;
  // The rand_skip variable is for the data layer to skip a few data points
  // to avoid all asynchronous sgd clients to start at the same point. The skip
  // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
  // be larger than the number of keys in the database.
  // DEPRECATED. Each solver accesses a different subset of the database.
  // rand_skip变量用于数据层跳过几个数据点,以避免所有异步sgd客户端在同一点开始。
  // 跳过点将被设置为rand_skip*rand(0,1)。请注意,rand_skip不应该大于数据库中的键数。
  // 已过时。每个求解器访问数据库的不同子集。
  optional uint32 rand_skip = 7 [default = 0];
  optional DB backend = 8 [default = LEVELDB];
  // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
  // simple scaling and subtracting the data mean, if provided. Note that the
  // mean subtraction is always carried out before scaling.
  // 过时了。参见TransformationParameter。
  // 如果使用数据预处理,我们可以做一些简单的尺度化和对数据均值的减法。
  // 注意,减法操作在尺度化操作之前
  optional float scale = 2 [default = 1];
  optional string mean_file = 3;
  // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
  // crop an image.
  // 过时了,参见TransformationParameter。指定是否要随机裁剪图片。
  optional uint32 crop_size = 5 [default = 0];
  // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
  // data.
  // 过时了,参见TransformationParameter。指定是否要随机镜像(拷贝)数据。
  optional bool mirror = 6 [default = false];
  // Force the encoded image to have 3 color channels
  // 强制将图像编码成三通道颜色,默认设置为否
  optional bool force_encoded_color = 9 [default = false];
  // Prefetch queue (Number of batches to prefetch to host memory, increase if
  // data access bandwidth varies).
  // 预取队列(要预取到主机内存的批次数,如果数据访问带宽变化则增加)。
  optional uint32 prefetch = 10 [default = 4];
}

message DropoutParameter {
  optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio:衰减率,默认设置为0.5
  optional bool scale_train = 2 [default = true];  // scale train or test phase:尺度化训练或测试状态
}

// DummyDataLayer fills any number of arbitrarily shaped blobs with random
// (or constant) data generated by "Fillers" (see "message FillerParameter").
//  假数据层用随机填充任意数量的任意形状的斑点 (或常量)由“填充器”生成的数据(见“消息填充参数”)。
message DummyDataParameter {
  // This layer produces N >= 1 top blobs.  DummyDataParameter must specify 1 or N
  // shape fields, and 0, 1 or N data_fillers.
  // 该层产生N> = 1个顶部blob。 假数据层必须指定1或N形状字段,以及0,1或N data_fillers。
  // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used.
  // 如果数据填充器指定为0,使用值为0的常数填充器。
  // If 1 data_filler is specified, it is applied to all top blobs.  If N are
  // specified, the ith is applied to the ith top blob.
  // 如果数据填充器指定为1,应用所有的顶层blobs。
  // 如果数据填充器指定为N,i应用第i的顶层blobs
  repeated FillerParameter data_filler = 1;
  repeated BlobShape shape = 6;

  // 4D dimensions -- deprecated.  Use "shape" instead.
  repeated uint32 num = 2;
  repeated uint32 channels = 3;
  repeated uint32 height = 4;
  repeated uint32 width = 5;
}

message EltwiseParameter {
  enum EltwiseOp {
    PROD = 0;
    SUM = 1;
    MAX = 2;
  }
  optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation:元素操作
  repeated float coeff = 2; // blob-wise coefficient for SUM operation:用于SUM操作的blob系数

  // Whether to use an asymptotically slower (for >2 inputs) but stabler method
  // of computing the gradient for the PROD operation. (No effect for SUM op.)
  // 是否使用渐近较慢(用于> 2个输入),但是计算PROD操作的梯度的稳定方法。(SUM操作无效)
  optional bool stable_prod_grad = 3 [default = true];
}

// Message that stores parameters used by ELULayer
message ELUParameter {
  // Described in:
  // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate
  // Deep Network Learning by Exponential Linear Units (ELUs). arXiv
  optional float alpha = 1 [default = 1];
}

// Message that stores parameters used by EmbedLayer
// 被用作嵌入层的存储参数的消息结构
message EmbedParameter {
  optional uint32 num_output = 1; // The number of outputs for the layer
  // The input is given as integers to be interpreted as one-hot
  // vector indices with dimension num_input.  Hence num_input should be
  // 1 greater than the maximum possible input value.
  // 输入作为整数给出,以被解释为具有num_input维的一热矢量索引。
  // 因此数值输入应该大于最大可能输入值的1。
  optional uint32 input_dim = 2;

  optional bool bias_term = 3 [default = true]; // Whether to use a bias term
  optional FillerParameter weight_filler = 4; // The filler for the weight
  optional FillerParameter bias_filler = 5; // The filler for the bias

}

// Message that stores parameters used by ExpLayer
// 被用作指数层的存储参数的消息结构
message ExpParameter {
  // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0.
  // Or if base is set to the default (-1), base is set to e,
  // so y = exp(shift + scale * x).
  optional float base = 1 [default = -1.0];
  optional float scale = 2 [default = 1.0];
  optional float shift = 3 [default = 0.0];
}

/// Message that stores parameters used by FlattenLayer
/// 被用作打散层的存储参数的消息结构
message FlattenParameter {
  // The first axis to flatten: all preceding axes are retained in the output.
  // May be negative to index from the end (e.g., -1 for the last axis).
  optional int32 axis = 1 [default = 1];
  // 第一轴展平:所有前面的轴都保留在输出中。
  // 可以从末尾开始索引(例如,对于最后一个轴为-1)。

  // The last axis to flatten: all following axes are retained in the output.
  // May be negative to index from the end (e.g., the default -1 for the last
  // axis).
  optional int32 end_axis = 2 [default = -1];
}

// Message that stores parameters used by HDF5DataLayer
// 被用作HDF5数据层的存储参数的消息结构
message HDF5DataParameter {
  // Specify the data source.
  optional string source = 1;
  // Specify the batch size.
  optional uint32 batch_size = 2;

  // Specify whether to shuffle the data.
  // If shuffle == true, the ordering of the HDF5 files is shuffled,
  // and the ordering of data within any given HDF5 file is shuffled,
  // but data between different files are not interleaved; all of a file's
  // data are output (in a random order) before moving onto another file.
  // 如果shuffle == true,则HDF5文件的顺序被打乱,并且任何给定HDF5文件内的数据的顺序被打乱,
  // 但是不同文件之间的数据不交错; 所有文件的数据在移动到另一个文件之前被输出(以随机顺序)。
  optional bool shuffle = 3 [default = false];
}

message HDF5OutputParameter {
  optional string file_name = 1;
}

message HingeLossParameter {
  enum Norm {
    L1 = 1;
    L2 = 2;
  }
  // Specify the Norm to use L1 or L2
  // 指定正则化为L1或者L2,默认为L1
  optional Norm norm = 1 [default = L1];
}

message ImageDataParameter {
  // Specify the data source.
  optional string source = 1;
  // Specify the batch size.
  optional uint32 batch_size = 4 [default = 1];
  // The rand_skip variable is for the data layer to skip a few data points
  // to avoid all asynchronous sgd clients to start at the same point. The skip
  // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
  // be larger than the number of keys in the database.
  optional uint32 rand_skip = 7 [default = 0];
  // Whether or not ImageLayer should shuffle the list of files at every epoch.
  // 是否图像层应该在每个时期打乱文件列表。默认不打乱
  optional bool shuffle = 8 [default = false];
  // It will also resize images if new_height or new_width are not zero.
  // 如果图像新的高度和宽度不是零,那么更改图像尺寸
  optional uint32 new_height = 9 [default = 0];
  optional uint32 new_width = 10 [default = 0];
  // Specify if the images are color or gray
  // 指定图像是彩色的还是灰度的
  optional bool is_color = 11 [default = true];
  // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
  // simple scaling and subtracting the data mean, if provided. Note that the
  // mean subtraction is always carried out before scaling.
  optional float scale = 2 [default = 1];
  optional string mean_file = 3;
  // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
  // crop an image.
  optional uint32 crop_size = 5 [default = 0];
  // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
  // data.
  optional bool mirror = 6 [default = false];
  optional string root_folder = 12 [default = ""];
}

message InfogainLossParameter {
  // Specify the infogain matrix source.
  // 指定 infogain的矩阵数据源
  optional string source = 1;
}

message InnerProductParameter {
  optional uint32 num_output = 1; // The number of outputs for the layer
  optional bool bias_term = 2 [default = true]; // whether to have bias terms
  optional FillerParameter weight_filler = 3; // The filler for the weight
  optional FillerParameter bias_filler = 4; // The filler for the bias

  // The first axis to be lumped into a single inner product computation;
  // all preceding axes are retained in the output.
  // 第一个轴要集中到单个内积计算中;所有前面的轴都保留在输出中。
  // May be negative to index from the end (e.g., -1 for the last axis).
  optional int32 axis = 5 [default = 1];
}

// Message that stores parameters used by LogLayer
//   被用作对数层的存储参数的消息结构
message LogParameter {
  // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0.
  // Or if base is set to the default (-1), base is set to e,
  // so y = ln(shift + scale * x) = log_e(shift + scale * x)
  optional float base = 1 [default = -1.0];
  optional float scale = 2 [default = 1.0];
  optional float shift = 3 [default = 0.0];
}

// Message that stores parameters used by LRNLayer
//   被用作LRN层的存储参数的消息结构
message LRNParameter {
  optional uint32 local_size = 1 [default = 5];
  optional float alpha = 2 [default = 1.];
  optional float beta = 3 [default = 0.75];
  enum NormRegion {
    ACROSS_CHANNELS = 0;
    WITHIN_CHANNEL = 1;
  }
  optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
  optional float k = 5 [default = 1.];
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 6 [default = DEFAULT];
}

message MemoryDataParameter {
  optional uint32 batch_size = 1;
  optional uint32 channels = 2;
  optional uint32 height = 3;
  optional uint32 width = 4;
}

message MVNParameter {
  // This parameter can be set to false to normalize mean only
  // 此参数可以设置为假以仅对平均值进行标准化
  optional bool normalize_variance = 1 [default = true];

  // This parameter can be set to true to perform DNN-like MVN
  // 此参数可以设置为真对类似DNN的MVN
  optional bool across_channels = 2 [default = false];

  // Epsilon for not dividing by zero while normalizing variance
  optional float eps = 3 [default = 1e-9];
}

message PoolingParameter {
  enum PoolMethod {
    MAX = 0; //最大值
    AVE = 1; // 平均值
    STOCHASTIC = 2;// 随机
  }
  optional PoolMethod pool = 1 [default = MAX]; // The pooling method
  // Pad, kernel size, and stride are all given as a single value for equal
  // dimensions in height and width or as Y, X pairs.
  optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X)
  optional uint32 pad_h = 9 [default = 0]; // The padding height:填充
  optional uint32 pad_w = 10 [default = 0]; // The padding width
  optional uint32 kernel_size = 2; // The kernel size (square)
  optional uint32 kernel_h = 5; // The kernel height:内核
  optional uint32 kernel_w = 6; // The kernel width
  optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X)
  optional uint32 stride_h = 7; // The stride height:步进
  optional uint32 stride_w = 8; // The stride width
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 11 [default = DEFAULT];
  // If global_pooling then it will pool over the size of the bottom by doing
  // kernel_h = bottom->height and kernel_w = bottom->width
  // 如果全局池化那么它将通过做池底部的大小
  // kernel_h = bottom-> height,kernel_w = bottom-> width
  optional bool global_pooling = 12 [default = false];
}

message PowerParameter {
  // PowerLayer computes outputs y = (shift + scale * x) ^ power.
  optional float power = 1 [default = 1.0];
  optional float scale = 2 [default = 1.0];
  optional float shift = 3 [default = 0.0];
}

message PythonParameter {
  optional string module = 1;
  optional string layer = 2;
  // This value is set to the attribute `param_str` of the `PythonLayer` object
  // in Python before calling the `setup()` method. This could be a number,
  // string, dictionary in Python dict format, JSON, etc. You may parse this
  // string in `setup` method and use it in `forward` and `backward`.
  // 该值设置为`PythonLayer`对象的`param_str`属性
  // 在Python中调用`setup()`方法。 这可能是一个数字,
  // 字符串,Python dict格式的字典,JSON等。你可以解析这个
  // 字符串在`setup`方法中,并在`forward`和`backward`中使用它。
  optional string param_str = 3 [default = ''];
  // Whether this PythonLayer is shared among worker solvers during data parallelism.
  // If true, each worker solver sequentially run forward from this layer.
  // This value should be set true if you are using it as a data layer.
  // 在数据并行期间,这个Python层是否在工作者解算器之间共享。
  // 如果为真,则每个工作解算器从该层顺序地向前运行。
  // 如果将其用作数据层,则此值应设置为真。
  optional bool share_in_parallel = 4 [default = false];
}

// Message that stores parameters used by ReductionLayer
//   被用作减少层的存储参数的消息结构
message ReductionParameter {
  enum ReductionOp {
    SUM = 1;
    ASUM = 2;
    SUMSQ = 3;
    MEAN = 4;
  }

  optional ReductionOp operation = 1 [default = SUM]; // reduction operation

  // The first axis to reduce to a scalar -- may be negative to index from the
  // end (e.g., -1 for the last axis).
  // (Currently, only reduction along ALL "tail" axes is supported; reduction
  // of axis M through N, where N < num_axes - 1, is unsupported.)
  // Suppose we have an n-axis bottom Blob with shape:
  //     (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)).
  // 减小到标量的第一轴 - 可以从端部索引为负(例如,对于最后一个轴为-1)。
  // (目前,仅支持沿着所有“尾”轴的缩减;轴M到N的缩减,其中N <num_axes-1不被支持)
  // 假设我们有一个n轴底部Blob形状:
  // (d0,d1,d2,...,d(m-1),dm,d(m + 1),...,d(n-1))。
  // If axis == m, the output Blob will have shape
  //     (d0, d1, d2, ..., d(m-1)),
  // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1))
  // times, each including (dm * d(m+1) * ... * d(n-1)) individual data.
  // If axis == 0 (the default), the output Blob always has the empty shape
  // (count 1), performing reduction across the entire input --
  // often useful for creating new loss functions.
  // 如果axis == m,则输出Blob将具有形状(d0,d1,d2,...,d(m-1)),
  // 并执行reduceOp操作(d0 * d1 * d2 * ... * d(m-1))
  // 每个包括(dm * d(m + 1)* ... * d(n-1))个体数据。
  // 如果axis == 0(默认值),输出Blob总是具有空的形状
  // (计数1),在整个输入执行减少 - 通常用于创建新的损失函数
  optional int32 axis = 2 [default = 0];

  optional float coeff = 3 [default = 1.0]; // coefficient for output
}

// Message that stores parameters used by ReLULayer
// 被用作ReLU层的存储参数的消息结构
message ReLUParameter {
  // Allow non-zero slope for negative inputs to speed up optimization
  // 对负输入允许非零斜率以加速优化,在下面这篇文章中描述
  // Described in:
  // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities
  // improve neural network acoustic models. In ICML Workshop on Deep Learning
  // for Audio, Speech, and Language Processing.
  optional float negative_slope = 1 [default = 0];
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 2 [default = DEFAULT];
}

message ReshapeParameter {
  // Specify the output dimensions. If some of the dimensions are set to 0,
  // the corresponding dimension from the bottom layer is used (unchanged).
  // Exactly one dimension may be set to -1, in which case its value is
  // inferred from the count of the bottom blob and the remaining dimensions.
  // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8:
  // 指定输出尺寸。 如果某些维度设置为0, 使用来自底层的相应尺寸(不变)。
  // 正好一个维度可以设置为-1,在这种情况下,其值为
  // 从底部斑点的数量和剩余尺寸推断。 例如,假设我们想用形状2×8重塑二维块“输入”:
  //   layer {
  //     type: "Reshape" bottom: "input" top: "output"
  //     reshape_param { ... }
  //   }
  //
  // If "input" is 2D with shape 2 x 8, then the following reshape_param
  // specifications are all equivalent, producing a 3D blob "output" with shape
  // 2 x 2 x 4:
  // 如果输入2D信息为 2 x 8,那么以下reshape_param规范都是等效的,
  // 从而产生具有形状的3D团块“输出”  2×2×4:
  //
  //   reshape_param { shape { dim:  2  dim: 2  dim:  4 } }
  //   reshape_param { shape { dim:  0  dim: 2  dim:  4 } }
  //   reshape_param { shape { dim:  0  dim: 2  dim: -1 } }
  //   reshape_param { shape { dim: -1  dim: 0  dim:  2 } }
  //
  optional BlobShape shape = 1;

  // axis and num_axes control the portion of the bottom blob's shape that are
  // replaced by (included in) the reshape. By default (axis == 0 and
  // num_axes == -1), the entire bottom blob shape is included in the reshape,
  // and hence the shape field must specify the entire output shape.
  // axis和num_axes控制底部blob的形状的部分 替换为(包含)重塑。 默认情况下(axis == 0和
  // num_axes == -1),整个底部斑点形状包括在重塑中, 因此形状字段必须指定整个输出形状。
  // axis may be non-zero to retain some portion of the beginning of the input
  // shape (and may be negative to index from the end; e.g., -1 to begin the
  // reshape after the last axis, including nothing in the reshape,
  // -2 to include only the last axis, etc.).
  // 轴可以是非零的,以保留输入的开始的一些部分 形状(并且可以从末端索引为负;例如,-1开始
  // 在最后一个轴后重塑,包括没有什么在重塑, -2仅包括最后一个轴等)。
  //
  // For example, suppose "input" is a 2D blob with shape 2 x 8.
  // Then the following ReshapeLayer specifications are all equivalent,
  // producing a blob "output" with shape 2 x 2 x 4:
  //
  //   reshape_param { shape { dim: 2  dim: 2  dim: 4 } }
  //   reshape_param { shape { dim: 2  dim: 4 } axis:  1 }
  //   reshape_param { shape { dim: 2  dim: 4 } axis: -3 }
  //
  // num_axes specifies the extent of the reshape.
  // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on
  // input axes in the range [axis, axis+num_axes].
  // num_axes may also be -1, the default, to include all remaining axes
  // (starting from axis).
  // num_axes指定重塑的范围。 如果num_axes> = 0(且轴> = 0),则将仅执行reshape
  // 输入轴在[axis,axis + num_axes]范围内。 num_axes也可以是默认值-1,以包括所有其余轴 (从轴开始)。
  //
  // For example, suppose "input" is a 2D blob with shape 2 x 8.
  // Then the following ReshapeLayer specifications are equivalent,
  // producing a blob "output" with shape 1 x 2 x 8.
  //
  //   reshape_param { shape { dim:  1  dim: 2  dim:  8 } }
  //   reshape_param { shape { dim:  1  dim: 2  }  num_axes: 1 }
  //   reshape_param { shape { dim:  1  }  num_axes: 0 }
  //
  // On the other hand, these would produce output blob shape 2 x 1 x 8:
  //
  //   reshape_param { shape { dim: 2  dim: 1  dim: 8  }  }
  //   reshape_param { shape { dim: 1 }  axis: 1  num_axes: 0 }
  //
  optional int32 axis = 2 [default = 0];
  optional int32 num_axes = 3 [default = -1];
}

// Message that stores parameters used by ROIPoolingLayer
// 被用作ROI池化层的存储参数的消息结构
message ROIPoolingParameter {
  // Pad, kernel size, and stride are all given as a single value for equal
  // dimensions in height and width or as Y, X pairs.
  optional uint32 pooled_h = 1 [default = 0]; // The pooled output height
  optional uint32 pooled_w = 2 [default = 0]; // The pooled output width
  // Multiplicative spatial scale factor to translate ROI coords from their
  // input scale to the scale used when pooling
  // 乘法空间比例因子,用于将ROI坐标从其输入量表转换为合并时使用的量表
  optional float spatial_scale = 3 [default = 1];
}

message ScaleParameter {
  // The first axis of bottom[0] (the first input Blob) along which to apply
  // bottom[1] (the second input Blob).  May be negative to index from the end
  // (e.g., -1 for the last axis).
  //
  // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
  // top[0] will have the same shape, and bottom[1] may have any of the
  // following shapes (for the given value of axis):
  //    (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
  //    (axis == 1 == -3)          3;     3x40;     3x40x60
  //    (axis == 2 == -2)                   40;       40x60
  //    (axis == 3 == -1)                                60
  // Furthermore, bottom[1] may have the empty shape (regardless of the value of
  // "axis") -- a scalar multiplier.
  optional int32 axis = 1 [default = 1];

  // (num_axes is ignored unless just one bottom is given and the scale is
  // a learned parameter of the layer.  Otherwise, num_axes is determined by the
  // number of axes by the second bottom.)
  // (忽略num_axes,除非只给出一个底部,并且比例为 该层的学习参数。 否则,num_axes由
  // 轴的数量由第二个底部决定。)
  // The number of axes of the input (bottom[0]) covered by the scale
  // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
  // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar.
  // 由数轴的输入( bottom[0])的尺度参数覆盖,或-1覆盖从`axis`开始的底部[0]的所有轴。
  // 设置num_axes为0,乘以零轴Blob(一个标量)。
  optional int32 num_axes = 2 [default = 1];

  // (filler is ignored unless just one bottom is given and the scale is
  // a learned parameter of the layer.)
  // 仅有一个bottom的时候填充被忽略,尺度就是该层的学习参数
  // The initialization for the learned scale parameter.
  // 学习尺度参数的初始化.
  // Default is the unit (1) initialization, resulting in the ScaleLayer
  // initially performing the identity operation.
  // 默认单元(1)初始化,从而在尺度层初始化执行单位操作。
  optional FillerParameter filler = 3;

  // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but
  // may be more efficient).  Initialized with bias_filler (defaults to 0).
  optional bool bias_term = 4 [default = false];
  optional FillerParameter bias_filler = 5;
}

message SigmoidParameter {
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 1 [default = DEFAULT];
}

message SmoothL1LossParameter {
  // SmoothL1Loss(x) =
  //   0.5 * (sigma * x) ** 2    -- if x < 1.0 / sigma / sigma
  //   |x| - 0.5 / sigma / sigma -- otherwise
  optional float sigma = 1 [default = 1];
}

message SliceParameter {
  // The axis along which to slice -- may be negative to index from the end
  // (e.g., -1 for the last axis).
  // By default, SliceLayer concatenates blobs along the "channels" axis (1).
  optional int32 axis = 3 [default = 1];
  repeated uint32 slice_point = 2;

  // DEPRECATED: alias for "axis" -- does not support negative indexing.
  optional uint32 slice_dim = 1 [default = 1];
}

// Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer
// 被用作Softmax,SoftmaxWithLoss层的存储参数的消息结构
message SoftmaxParameter {
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 1 [default = DEFAULT];

  // The axis along which to perform the softmax -- may be negative to index
  // from the end (e.g., -1 for the last axis).
  // 跟着softmax的主轴执行,可能是负数,如果是负数,则为逆序索引
  // Any other axes will be evaluated as independent softmaxes.
  // 其他任何轴被评为softmax的独立值
  optional int32 axis = 2 [default = 1];
}

message TanHParameter {
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 1 [default = DEFAULT];
}

// Message that stores parameters used by TileLayer
// 被用作TileLayer层的存储参数的消息结构
message TileParameter {
  // The index of the axis to tile.
  optional int32 axis = 1 [default = 1];

  // The number of copies (tiles) of the blob to output.
  optional int32 tiles = 2;
}

// Message that stores parameters used by ThresholdLayer
// 被用作阈值化层的存储参数的消息结构
message ThresholdParameter {
  optional float threshold = 1 [default = 0]; // Strictly positive values //必须为正数
}

message WindowDataParameter {
  // Specify the data source.//指定数据源
  optional string source = 1; //源名
  // For data pre-processing, we can do simple scaling and subtracting the
  // data mean, if provided. Note that the mean subtraction is always carried
  // out before scaling.
  optional float scale = 2 [default = 1];//尺度
  optional string mean_file = 3;//均值文件
  // Specify the batch size.
  optional uint32 batch_size = 4;//块文件
  // Specify if we would like to randomly crop an image.//是否指定随机剪裁图像
  optional uint32 crop_size = 5 [default = 0];//剪裁尺寸
  // Specify if we want to randomly mirror data.//是否指定随机镜像图像
  optional bool mirror = 6 [default = false];//默认不镜像
  // Foreground (object) overlap threshold //前景(对象)重叠阈值
  optional float fg_threshold = 7 [default = 0.5];//默认0.5
  // Background (non-object) overlap threshold//背景(对象)重叠阈值
  optional float bg_threshold = 8 [default = 0.5];//默认0.5
  // Fraction of batch that should be foreground objects//块的一部分可能是前景一部分
  optional float fg_fraction = 9 [default = 0.25];//默认值为0.25
  // Amount of contextual padding to add around a window
  // 在窗口周围上文添加量
  // (used only by the window_data_layer) //仅用作窗口数据层
  optional uint32 context_pad = 10 [default = 0];
  // Mode for cropping out a detection window
  // 剪裁检测窗口的模式
  // warp: cropped window is warped to a fixed size and aspect ratio
  // 拉伸:将窗口拉伸到固定尺寸和纵横比大小
  // square: the tightest square around the window is cropped
  // 方形:按照窗口的最小矩形选定大小
  optional string crop_mode = 11 [default = "warp"]; //默认为“warp” 模式
  // cache_images: will load all images in memory for faster access
  // 缓存图片:将所有图片导入到内存中用来加快访问速度
  optional bool cache_images = 12 [default = false];
  // append root_folder to locate images
  // 添加根目录路径以查找图片
  optional string root_folder = 13 [default = ""];
}

message SPPParameter {
  enum PoolMethod {
    MAX = 0;
    AVE = 1;
    STOCHASTIC = 2;
  }
  optional uint32 pyramid_height = 1;
  optional PoolMethod pool = 2 [default = MAX]; // The pooling method //池化方法:最大值
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 6 [default = DEFAULT];
}

// DEPRECATED: use LayerParameter.
message V1LayerParameter {
  repeated string bottom = 2;
  repeated string top = 3;
  optional string name = 4;
  repeated NetStateRule include = 32;
  repeated NetStateRule exclude = 33;
  enum LayerType {
    NONE = 0;
    ABSVAL = 35;
    ACCURACY = 1;
    ARGMAX = 30;
    BNLL = 2;
    CONCAT = 3;
    CONTRASTIVE_LOSS = 37;
    CONVOLUTION = 4;
    DATA = 5;
    DECONVOLUTION = 39;
    DROPOUT = 6;
    DUMMY_DATA = 32;
    EUCLIDEAN_LOSS = 7;
    ELTWISE = 25;
    EXP = 38;
    FLATTEN = 8;
    HDF5_DATA = 9;
    HDF5_OUTPUT = 10;
    HINGE_LOSS = 28;
    IM2COL = 11;
    IMAGE_DATA = 12;
    INFOGAIN_LOSS = 13;
    INNER_PRODUCT = 14;
    LRN = 15;
    MEMORY_DATA = 29;
    MULTINOMIAL_LOGISTIC_LOSS = 16;
    MVN = 34;
    POOLING = 17;
    POWER = 26;
    RELU = 18;
    SIGMOID = 19;
    SIGMOID_CROSS_ENTROPY_LOSS = 27;
    SILENCE = 36;
    SOFTMAX = 20;
    SOFTMAX_LOSS = 21;
    SPLIT = 22;
    SLICE = 33;
    TANH = 23;
    WINDOW_DATA = 24;
    THRESHOLD = 31;
  }
  optional LayerType type = 5;
  repeated BlobProto blobs = 6;
  repeated string param = 1001;
  repeated DimCheckMode blob_share_mode = 1002;
  enum DimCheckMode {
    STRICT = 0;
    PERMISSIVE = 1;
  }
  repeated float blobs_lr = 7;
  repeated float weight_decay = 8;
  repeated float loss_weight = 35;
  optional AccuracyParameter accuracy_param = 27;
  optional ArgMaxParameter argmax_param = 23;
  optional ConcatParameter concat_param = 9;
  optional ContrastiveLossParameter contrastive_loss_param = 40;
  optional ConvolutionParameter convolution_param = 10;
  optional DataParameter data_param = 11;
  optional DropoutParameter dropout_param = 12;
  optional DummyDataParameter dummy_data_param = 26;
  optional EltwiseParameter eltwise_param = 24;
  optional ExpParameter exp_param = 41;
  optional HDF5DataParameter hdf5_data_param = 13;
  optional HDF5OutputParameter hdf5_output_param = 14;
  optional HingeLossParameter hinge_loss_param = 29;
  optional ImageDataParameter image_data_param = 15;
  optional InfogainLossParameter infogain_loss_param = 16;
  optional InnerProductParameter inner_product_param = 17;
  optional LRNParameter lrn_param = 18;
  optional MemoryDataParameter memory_data_param = 22;
  optional MVNParameter mvn_param = 34;
  optional PoolingParameter pooling_param = 19;
  optional PowerParameter power_param = 21;
  optional ReLUParameter relu_param = 30;
  optional SigmoidParameter sigmoid_param = 38;
  optional SoftmaxParameter softmax_param = 39;
  optional SliceParameter slice_param = 31;
  optional TanHParameter tanh_param = 37;
  optional ThresholdParameter threshold_param = 25;
  optional WindowDataParameter window_data_param = 20;
  optional TransformationParameter transform_param = 36;
  optional LossParameter loss_param = 42;
  optional V0LayerParameter layer = 1;
}

// DEPRECATED: V0LayerParameter is the old way of specifying layer parameters
// in Caffe.  We keep this message type around for legacy support.
//  舍弃:V0LayerParameter参数是Caffe中指定层参数的旧方式。此处保留是为了向下兼容考虑。
message V0LayerParameter {
  optional string name = 1; // the layer name
  optional string type = 2; // the string to specify the layer type

  // Parameters to specify layers with inner products.
  // 指定层与层之间内积参数
  optional uint32 num_output = 3; // The number of outputs for the layer
  optional bool biasterm = 4 [default = true]; // whether to have bias terms
  optional FillerParameter weight_filler = 5; // The filler for the weight
  optional FillerParameter bias_filler = 6; // The filler for the bias

  optional uint32 pad = 7 [default = 0]; // The padding size
  optional uint32 kernelsize = 8; // The kernel size
  optional uint32 group = 9 [default = 1]; // The group size for group conv
  optional uint32 stride = 10 [default = 1]; // The stride
  enum PoolMethod {
    MAX = 0;
    AVE = 1;
    STOCHASTIC = 2;
  }
  optional PoolMethod pool = 11 [default = MAX]; // The pooling method
  optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio //默认衰减因子0.5

  optional uint32 local_size = 13 [default = 5]; // for local response norm//默认局部尺寸5
  optional float alpha = 14 [default = 1.]; // for local response norm//alpha = 1
  optional float beta = 15 [default = 0.75]; // for local response norm//beta = 0.75
  optional float k = 22 [default = 1.];// k = 1

  // For data layers, specify the data source
  optional string source = 16;
  // For data pre-processing, we can do simple scaling and subtracting the
  // data mean, if provided. Note that the mean subtraction is always carried
  // out before scaling.
  optional float scale = 17 [default = 1];
  optional string meanfile = 18;
  // For data layers, specify the batch size.
  optional uint32 batchsize = 19;
  // For data layers, specify if we would like to randomly crop an image.
  optional uint32 cropsize = 20 [default = 0];
  // For data layers, specify if we want to randomly mirror data.
  optional bool mirror = 21 [default = false];

  // The blobs containing the numeric parameters of the layer
  repeated BlobProto blobs = 50;
  // The ratio that is multiplied on the global learning rate. If you want to
  // set the learning ratio for one blob, you need to set it for all blobs.
  repeated float blobs_lr = 51;
  // The weight decay that is multiplied on the global weight decay.
  repeated float weight_decay = 52;

  // The rand_skip variable is for the data layer to skip a few data points
  // to avoid all asynchronous sgd clients to start at the same point. The skip
  // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
  // be larger than the number of keys in the database.
  // rand_skip变量用于数据层跳过几个数据点
  // 以避免所有异步sgd客户端在同一点启动。 跳过
  // 点将被设置为rand_skip * rand(0,1)。 请注意,rand_skip不应该
  // 大于数据库中的关键点数。
  optional uint32 rand_skip = 53 [default = 0];

  // Fields related to detection (det_*)
  // foreground (object) overlap threshold // 前景重叠阈值
  optional float det_fg_threshold = 54 [default = 0.5];
  // background (non-object) overlap threshold // 背景重叠阈值
  optional float det_bg_threshold = 55 [default = 0.5];
  // Fraction of batch that should be foreground objects
  // 图像块组的部分应该前景的概率,默认值为0.25
  optional float det_fg_fraction = 56 [default = 0.25];

  // optional bool OBSOLETE_can_clobber = 57 [default = true];

  // Amount of contextual padding to add around a window
  // 在窗口周围添加的上下填充量,仅被用作窗口数据层
  // (used only by the window_data_layer)
  optional uint32 det_context_pad = 58 [default = 0];

  // Mode for cropping out a detection window
  // warp: cropped window is warped to a fixed size and aspect ratio
  // square: the tightest square around the window is cropped
  optional string det_crop_mode = 59 [default = "warp"];

  // For ReshapeLayer, one needs to specify the new dimensions.
  // 对于Reshape层,需要指定新维度。
  optional int32 new_num = 60 [default = 0];
  optional int32 new_channels = 61 [default = 0];
  optional int32 new_height = 62 [default = 0];
  optional int32 new_width = 63 [default = 0];

  // Whether or not ImageLayer should shuffle the list of files at every epoch.
  // It will also resize images if new_height or new_width are not zero.
  // 图像层是否应该在每个时期打乱文件列表
  // 如果新的宽度和高度不为零,那么图像将会重新指定尺寸
  optional bool shuffle_images = 64 [default = false];

  // For ConcatLayer, one needs to specify the dimension for concatenation, and
  // the other dimensions must be the same for all the bottom blobs.
  // By default it will concatenate blobs along the channels dimension.
  // 对于ConcatLayer,需要指定用于级联的维度
  // 所有底部斑点的其他尺寸必须相同。
  // 默认情况下,它将沿通道维度连接blob。
  optional uint32 concat_dim = 65 [default = 1];

  optional HDF5OutputParameter hdf5_output_param = 1001;
}

message PReLUParameter {
  // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers:
  // Surpassing Human-Level Performance on ImageNet Classification, 2015.
  // 参数ReLU出自于Delving Deep into Rectifiers:Surpassing Human-Level Performance
  // on ImageNet Classification文章

  // Initial value of a_i. Default is a_i=0.25 for all i.
  // a_i的初始值,默认为0.25
  optional FillerParameter filler = 1;
  // Whether or not slope paramters are shared across channels.
  // 是否跨通道共享斜率参数
  optional bool channel_shared = 2 [default = false];
}

caffe.proto注释转自caffe.proto注释上并加以修改

syntax = "proto2";

package caffe;
//  repeated  required optional 
//  可重复,类似数组     必要的      可选的
// Specifies the shape (dimensions) of a Blob.
// n*c*w*h
message BlobShape {
  repeated int64 dim = 1 [packed = true];
}

message BlobProto {
  optional BlobShape shape = 7; //下文中替代4D描述符的结构
  repeated float data = 5 [packed = true];
  repeated float diff = 6 [packed = true];
  repeated double double_data = 8 [packed = true];
  repeated double double_diff = 9 [packed = true];

  // 4D dimensions -- deprecated.  Use "shape" instead.

  // 4维的描述方式舍弃掉,改用"BlobShape"结构替代
  optional int32 num = 1 [default = 0];
  optional int32 channels = 2 [default = 0];
  optional int32 height = 3 [default = 0];
  optional int32 width = 4 [default = 0];
}

// The BlobProtoVector is simply a way to pass multiple blobproto instances
// around.
message BlobProtoVector {
  repeated BlobProto blobs = 1;
}

//图像数据结构
message Datum {
  optional int32 channels = 1;
  optional int32 height = 2;
  optional int32 width = 3;
  // the actual image data, in bytes
  //实际上以字节存储图像内容
  optional bytes data = 4;
  optional int32 label = 5;
  // Optionally, the datum could also hold float data.
  repeated float float_data = 6;
  // If true data contains an encoded image that need to be decoded
  optional bool encoded = 7 [default = false];
}

message FillerParameter {
  // The filler type.
  optional string type = 1 [default = 'constant'];
  optional float value = 2 [default = 0]; // the value in constant filler
  optional float min = 3 [default = 0]; // the min value in uniform filler
  optional float max = 4 [default = 1]; // the max value in uniform filler
  optional float mean = 5 [default = 0]; // the mean value in Gaussian filler
  optional float std = 6 [default = 1]; // the std value in Gaussian filler
  // The expected number of non-zero output weights for a given input in
  // Gaussian filler -- the default -1 means don't perform sparsification.
  //非零的输出值以高斯滤波系数值的方式填充
  //默认值为-1,不进行稀疏化
  optional int32 sparse = 7 [default = -1];
  // Normalize the filler variance by fan_in, fan_out, or their average.
  // Applies to 'xavier' and 'msra' fillers.

  //Protocol Buffer中的枚举和C++中类似
  enum VarianceNorm {
    FAN_IN = 0;
    FAN_OUT = 1;
    AVERAGE = 2;
  }
  optional VarianceNorm variance_norm = 8 [default = FAN_IN];
}

//网络参数
message NetParameter {
  optional string name = 1; // consider giving the network a name
  // The input blobs to the network.
  repeated string input = 3;
  // The shape of the input blobs.
  repeated BlobShape input_shape = 8;

  // 4D input dimensions -- deprecated.  Use "shape" instead.
  // If specified, for each input blob there should be four
  // values specifying thenum, channels, height and width of the input blob.
  // Thus, there should be a total of (4 * #input) numbers.
  repeated int32 input_dim = 4;

  // Whether the network will force every layer to carry out backward operation.
  // If set False, then whether to carry out backward is determined
  // automatically according to the net structure and learning rates.
  //网络是否会迫使每一层都进行反向操作。
  //如果设置为False,则根据网络结构和学习速率自动确定是否执行反向传播操作。
  optional bool force_backward = 5 [default = false];
  // The current "state" of the network, including the phase, level, and stage.
  //当前的网络状态有phase,level,stage三种状态。
  // Some layers may be included/excluded depending on this state and the states
  // specified in the layers' include and exclude fields.
  //根据此状态和图层的包含和非包含字段中指定的状态,可以包括/排除某些网络层。
  optional NetState state = 6;

  // Print debugging information about results while running Net::Forward,
  // Net::Backward, and Net::Update.
  //当运行前向网络,后向网络,更新网络的时候打印调试信息,默认不打印
  optional bool debug_info = 7 [default = false];

  // The layers that make up the net.  Each of their configurations, including
  // connectivity and behavior, is specified as a LayerParameter.
  //很多层就构成了网络模型.连接和行为等配置参数构成了层参数.最后打印出来
  repeated LayerParameter layer = 100;  // ID 100 so layers are printed last.

  // DEPRECATED: use 'layer' instead.
  //此后改用'layer'结构
  repeated V1LayerParameter layers = 2;
}

// NOTE
// Update the next available ID when you add a new SolverParameter field.
//注意
//当你添加新的求解器参数对象时,更新了新的可用ID ,为 ID 41  type
//
// SolverParameter next available ID: 41 (last added: type)
//求解器参数
message SolverParameter {
  //////////////////////////////////////////////////////////////////////////////
  // Specifying the train and test networks
  //
  // Exactly one train net must be specified using one of the following fields:
  //     train_net_param, train_net, net_param, net
  // One or moretest nets may be specified using any of the following fields:
  //    test_net_param, test_net, net_param, net
  // If more than one test net field is specified (e.g., both net and
  // test_net are specified), they will be evaluated in the field order given
  // above: (1) test_net_param, (2) test_net, (3) net_param/net.
  //如果指定了多个测试网络字段(例如,指定了net和test_net),则将以上面给出的字段顺序对它们求值:
  //(1)test_net_param,(2)test_net,(3)net_param / net。
  // A test_iter must be specified for each test_net.
  // 必须为每个test_net 指定 test_iter
  // A test_level and/or a test_stage may also be specified for each test_net.
  // 还可以为每个test_net指定test_level和/或test_stage
  //////////////////////////////////////////////////////////////////////////////

  // Proto filename for the train net, possibly combined with one or more
  // test nets.
  //对于训练网络的原型文件名可能由一个或者多个训练网络组成。
  optional string net = 24;
  // Inline train net param, possibly combined with one or more test nets.
  // 内联训练网络参数可能含有一个或者多个测试网络
  optional NetParameter net_param = 25;

  optional string train_net = 1; // Proto filename for the train net.
  repeated string test_net = 2; // Proto filenames for the test nets.
  optional NetParameter train_net_param = 21; // Inline train net params.
  repeated NetParameter test_net_param = 22; // Inline test net params.

  // The states for the train/test nets. Must be unspecified or
  // specified once per net.
  //要么确定,要么不确定,一旦确定,要么全是测试网络要么全是训练网络
  //
  // By default, all states will have solver = true;
  // train_state will have phase = TRAIN,
  // and all test_state's will have phase = TEST.
  // Other defaults are set according to the NetState defaults.
  //默认的,所有求解器的状态为真.训练网络 phase = TRAIN,测试网络phase = TEST,
  //其他情况有网络状态的默认值决定

  optional NetState train_state = 26;
  repeated NetState test_state = 27;

  // The number of iterations for each test net.
  repeated int32 test_iter = 3;

  // The number of iterations between two testing phases.
  // 两个测试阶段之间的迭代次数。
  optional int32 test_interval = 4 [default = 0];
  optional bool test_compute_loss = 19 [default = false];
  // If true, run an initial test pass before the first iteration,
  // ensuring memory availability and printing the starting value of the loss.
  // 若为真,在执行第一次迭代之前,先得运行初始化测试通过来确保有足够存储资源和打印初始值的loss信息
  optional bool test_initialization = 32 [default = true];
  optional float base_lr = 5; // The base learning rate //基准学习率
  // the number of iterations between displaying info. If display = 0, no info
  // will be displayed.
  // 显示迭代之间显示信息,如果display = 0,则没有信息显示
  optional int32 display = 6;
  // Display the loss averaged over the last average_loss iterations
  // 显示上次average_loss迭代的平均损失
  optional int32 average_loss = 33 [default = 1];
  optional int32 max_iter = 7; // the maximum number of iterations
  // accumulate gradients over `iter_size` x `batch_size` instances
  optional int32 iter_size = 36 [default = 1];

  // The learning rate decay policy. The currently implemented learning rate
  // policies are as follows:
  //    - fixed: always returnbase_lr.
  //    - step: returnbase_lr *gamma ^ (floor(iter / step))
  //    - exp: returnbase_lr *gamma ^ iter
  //    - inv: returnbase_lr * (1 +gamma * iter) ^ (- power)
  //    - multistep: similar to step but it allows non uniform steps defined by
  //      stepvalue
  //    - poly: the effective learning rate follows a polynomial decay, to be
  //      zero by the max_iter. returnbase_lr (1 -iter/max_iter) ^ (power)
  //    - sigmoid: the effective learning rate follows a sigmod decay
  //      return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize))))
  //
  // where base_lr, max_iter, gamma, step, stepvalue and power are defined
  // in the solver parameter protocol buffer, and iter is the current iteration.
  optional string lr_policy = 8;
  optional float gamma = 9; // The parameter to compute the learning rate.
  optional float power = 10; // The parameter to compute the learning rate.
  optional float momentum = 11; // The momentum value. //动量值
  optional float weight_decay = 12; // The weight decay. //权重衰减
  // regularization types supported: L1 and L2
  // controlled by weight_decay
  //正则化方式支持:L1 和 L2
  //由权值衰减变量控制
  optional string regularization_type = 29 [default = "L2"]; //默认正则化方式为L2
  // the stepsize for learning rate policy "step"
  optional int32 stepsize = 13;
  // the stepsize for learning rate policy "multistep"
  repeated int32 stepvalue = 34;

  // Set clip_gradients to >= 0 to clip parameter gradients to that L2 norm,
  // whenever their actual L2 norm is larger.
  // 设置clip_gradients大于零,只要它比实际的L2范数大,那么它就等于L2范数 
  optional float clip_gradients = 35 [default = -1];

  optional int32 snapshot = 14 [default = 0]; // The snapshot interval  //snapshot:快照
  optional string snapshot_prefix = 15; // The prefix for the snapshot. //prefix:字首
  // whether to snapshot diff in the results or not. Snapshotting diff will help
  // debugging but the final protocol buffer size will be much larger.
  // 无论快照在结果中有无差值,快照的差值将会有助于调试,但是最终的protocol buffer的尺寸会大很多
  //
  optional bool snapshot_diff = 16 [default = false];
  enum SnapshotFormat {
    HDF5 = 0;
    BINARYPROTO = 1;
  }
  optional SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
  // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default.
  enum SolverMode {
    CPU = 0;
    GPU = 1;
  }
  optional SolverMode solver_mode = 17 [default = GPU];
  // the device_id will that be used in GPU mode. Use device_id = 0 in default.
  optional int32 device_id = 18 [default = 0];
  // If non-negative, the seed with which the Solver will initialize the Caffe
  // random number generator -- useful for reproducible results. Otherwise,
  // (and by default) initialize using a seed derived from the system clock.
  optional int64 random_seed = 20 [default = -1];

  // type of the solver
  //求解器的类型 默认类型为SGD
  optional string type = 40 [default = "SGD"]; //string 类型

  // numerical stability for RMSProp, AdaGrad and AdaDelta and Adam
  // 对于RMSProp, AdaGrad and AdaDelta and Adam的数值稳定性默认阈值为 1e-8
  optional float delta = 31 [default = 1e-8];
  // parameters for the Adam solver
  // 自适应动量求解器的衰减的默认取值为0.999
  optional float momentum2 = 39 [default = 0.999];

  // RMSProp decay value
  // RMSProp的衰减值
  // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t)
  // 均方差的迭代求解关系
  // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t)
  optional float rms_decay = 38;

  // If true, print information about the state of the net that may help with
  // debugging learning problems.
  // 是否打印调试信息,默认设置为否
  optional bool debug_info = 23 [default = false];

  // If false, don't save a snapshot after training finishes.
  //如何设置为否,则不保存每次训练结束后的快照
  optional bool snapshot_after_train = 28 [default = true];

  // DEPRECATED: old solver enum types, use string instead
  //舍弃旧的求解器枚举类型,使用string代替
  enum SolverType {
    SGD = 0;
    NESTEROV = 1;
    ADAGRAD = 2;
    RMSPROP = 3;
    ADADELTA = 4;
    ADAM = 5;
  }
  // DEPRECATED: use type instead of solver_type
  // 舍弃solver_type, 改用 type
  optional SolverType solver_type = 30 [default = SGD];
}

// A message that stores the solver snapshots
message SolverState {
  optional int32 iter = 1; // The current iteration //当前迭代
  optional string learned_net = 2; // The file that stores the learned net. //保存学习网络的文件
  repeated BlobProto history = 3; // The history for sgd solvers //sgd求解器的历史记录
  optional int32 current_step = 4 [default = 0]; // The current step for learning rate //当前学习率的步进
}

//状态枚举:训练或者测试
enum Phase { 
   TRAIN = 0;
   TEST = 1;
}

//网络状态
message NetState {
  optional Phase phase = 1 [default = TEST];
  optional int32 level = 2 [default = 0];
  repeated string stage = 3;
}

//Rule网络状态
message NetStateRule {
  // Set phase to require the NetState have a particular phase (TRAIN or TEST)
  // to meet this rule.
  optional Phase phase = 1;

  // Set the minimum and/or maximum levels in which the layer should be used.
  // Leave undefined to meet the rule regardless of level.
  //设置Rule层需使用的最大与/或最小层,其他未定义的层需满足rule规则。
  optional int32 min_level = 2;
  optional int32 max_level = 3;

  // Customizable sets of stages to include or exclude.
  //包含或排除用户自定义集的状态
  // The net must have ALL of the specified stages and NONE of the specified
  // "not_stage"s to meet the rule.
  //网络必须含有所有具体的状态,使用多层网络Rlue用于连接特定状态
  // (Use multiple NetStateRules to specify conjunctions of stages.)
  repeated string stage = 4;
  repeated string not_stage = 5;
}

// Specifies training parameters (multipliers on global learning constants,
// and the name and other settings used for weight sharing).
// 指定训练参数(多层网络的全局学习常数,以及用于权重分配的名称和其他设置)。
message ParamSpec {
  // The names of the parameter blobs -- useful for sharing parameters among
  // layers, but never required otherwise.  To share a parameter between two
  // layers, give it a (non-empty) name.
  // blobs参数的名称-用于在图层之间共享参数,但从不需要。为了共享一个参数给两层网络,给它一个名字
  optional string name = 1;

  // Whether to require shared weights to have the same shape, or just the same
  // count -- defaults to STRICT if unspecified.
  // 无论是为了相同的shape而共享权值,或者仅仅只是计数。默认情况下如果未指定则为STRICT(限制)
  // 
  optional DimCheckMode share_mode = 2;
  enum DimCheckMode {
    // STRICT (default) requires thatnum, channels, height, width each match.
    //STRICT 限制 (默认)num, channels, height, width为shape的四个参数,对应一一匹配
    STRICT = 0;
    // PERMISSIVE requires only the count (num*channels*height*width) to match.
    // PERMISSIVE 允许 仅需要num*channels*height*width的数相同即可
    PERMISSIVE = 1;
  }

  // The multiplier on the global learning rate for this parameter.
  //该参数在全局上的学习率的乘数
  optional float lr_mult = 3 [default = 1.0];

  // The multiplier on the global weight decay for this parameter.
  // 该参数在全局上的权值衰减的乘数
  optional float decay_mult = 4 [default = 1.0];
}

// NOTE
// Update the next available ID when you add a new LayerParameter field.
//注意
//当你增加新的网络参数字段时,更新新的可用ID
// LayerParameter next available layer-specific ID: 143 (last added: scale_param)
//   新的可用字段号为143
message LayerParameter {
  optional string name = 1; // the layer name
  optional string type = 2; // the layer type
  repeated string bottom = 3; // the name of each bottom blob
  repeated string top = 4; // the name of each top blob

  // The train / test phase for computation.
  optional Phase phase = 10;

  // The amount of weight to assign each top blob in the objective.
  // Each layer assigns a default value, usually of either 0 or 1,
  // to each top blob.
  // 在目标中分配每个顶部blob的权重量。每个图层为每个顶部blob分配一个默认值,通常为0或1。
  repeated float loss_weight = 5;

  // Specifies training parameters (multipliers on global learning constants,
  // and the name and other settings used for weight sharing).
  // 指定训练参数(全局学习常数的乘数,以及用于权值共享的名称和其他设置)。
  repeated ParamSpec param = 6;

  // The blobs containing the numeric parameters of the layer.
  // blob包含层的数值参数。
  repeated BlobProto blobs = 7;

  // Specifies on which bottoms the backpropagation should be skipped.
  //反向传播中指定应该跳过哪些bottoms
  // The size must be either 0 or equal to the number of bottoms.
  // 大小为0或者等于bottoms的个数
  repeated bool propagate_down = 11;

  // Rules controlling whether and when a layer is included in the network,
  // based on the current NetState.  You may specify a non-zero number of rules
  // to include OR exclude, but not both.  If no include or exclude rules are
  // specified, the layer is always included.  If the current NetState meets
  // ANY (i.e., one or more) of the specified rules, the layer is
  // included/excluded.
  // Rules 基于当前的网络状态控制该层是否包含在网络中,您可以指定非零数量的规则以包括或排除,但不能同时包含两者。
  // 如果未指定包含或排除规则,则始终包括该层。如果当前网络状态满足指定规则中的任意(即一个或多个),则包括/排除该层。
  repeated NetStateRule include = 8;
  repeated NetStateRule exclude = 9;

  // Parameters for data pre-processing.
  // 数据预处理的参数
  optional TransformationParameter transform_param = 100;

  // Parameters shared by loss layers.
  // 损耗层共享的参数。
  optional LossParameter loss_param = 101;

  // Layer type-specific parameters.
  // 层的各种具体类型的参数
  // Note: certain layers may have more than one computational engine
  // for their implementation. These layers include an Engine type and
  // engine parameter for selecting the implementation.
  // The default for the engine is set by the ENGINE switch at compile-time.
  // 注意:某些图层可能有多个计算引擎用于实现。
  // 这些层包括用于选择实现的引擎类型和引擎参数。
  // 引擎的默认值由编译时的ENGINE开关设置。
  optional AccuracyParameter accuracy_param = 102;//准确率
  optional ArgMaxParameter argmax_param = 103;//极大值
  optional BatchNormParameter batch_norm_param = 139;//块归一化
  optional BiasParameter bias_param = 141;//偏置
  optional ConcatParameter concat_param = 104;//连续
  optional ContrastiveLossParameter contrastive_loss_param = 105;//对比损失
  optional ConvolutionParameter convolution_param = 106;//卷积
  optional DataParameter data_param = 107;//数据
  optional DropoutParameter dropout_param = 108;//dropout
  optional DummyDataParameter dummy_data_param = 109;// 填充数据
  optional EltwiseParameter eltwise_param = 110;//eltwise
  optional ELUParameter elu_param = 140;//elu
  optional EmbedParameter embed_param = 137;//嵌入
  optional ExpParameter exp_param = 111;
  optional FlattenParameter flatten_param = 135;
  optional HDF5DataParameter hdf5_data_param = 112;//hdf5 输入参数
  optional HDF5OutputParameter hdf5_output_param = 113;//hdf5 数据输出参数
  optional HingeLossParameter hinge_loss_param = 114;//合并损失
  optional ImageDataParameter image_data_param = 115;//图像数据
  optional InfogainLossParameter infogain_loss_param = 116;//信息获取?infogain
  optional InnerProductParameter inner_product_param = 117;//全连接层参数
  optional LogParameter log_param = 134;//对数参数
  optional LRNParameter lrn_param = 118;//局部响应归一化参数
  optional MemoryDataParameter memory_data_param = 119;//内存数据参数
  optional MVNParameter mvn_param = 120;//mvn?
  optional PoolingParameter pooling_param = 121;池化参数
  optional PowerParameter power_param = 122;//能量参数
  optional PReLUParameter prelu_param = 131;//预Relu参数
  optional PythonParameter python_param = 130;//python参数
  optional ReductionParameter reduction_param = 136;//减少参数
  optional ReLUParameter relu_param = 123;//relu
  optional ReshapeParameter reshape_param = 133;//更改形状
  optional ROIPoolingParameter roi_pooling_param = 8266711;//ROI池化参数
  optional ScaleParameter scale_param = 142;//尺度化参数
  optional SigmoidParameter sigmoid_param = 124;//simgmoid参数
  optional SmoothL1LossParameter smooth_l1_loss_param = 8266712;//平滑l1损失参数
  optional SoftmaxParameter softmax_param = 125;//softmax参数
  optional SPPParameter spp_param = 132;//SPP参数
  optional SliceParameter slice_param = 126;//切片参数
  optional TanHParameter tanh_param = 127;//反正切参数
  optional ThresholdParameter threshold_param = 128;//阈值参数
  optional TileParameter tile_param = 138;tile参数
  optional WindowDataParameter window_data_param = 129;//window数据参数
}

// Message that stores parameters used to apply transformation
// to the data layer's data
// 存储将数据转换应用到数据层的消息结构
message TransformationParameter {
  // For data pre-processing, we can do simple scaling and subtracting the
  // data mean, if provided. Note that the mean subtraction is always carried
  // out before scaling.
  // 如果使用数据预处理,我们可以做一些简单的尺度化和对数据均值的减法。
  // 注意,减法操作在尺度化操作之前
  optional float scale = 1 [default = 1];
  // Specify if we want to randomly mirror data.
  optional bool mirror = 2 [default = false];
  // Specify if we would like to randomly crop an image.
  optional uint32 crop_size = 3 [default = 0];
  // mean_file and mean_value cannot be specified at the same time
  // 不能同时制定mean_file 和 mean_value
  optional string mean_file = 4;
  // if specified can be repeated once (would substract it from all the channels)
  // or can be repeated the same number of times as channels
  // (would subtract them from the corresponding channel)
   // 可有且仅可有一次(从所有通道中减去它)
   // 或者每个通道单独减去它们

  repeated float mean_value = 5;
  // Force the decoded image to have 3 color channels.
  // 强制解码成三通道颜色
  optional bool force_color = 6 [default = false];
  // Force the decoded image to have 1 color channels.
  // 强制解码成单通道颜色
  optional bool force_gray = 7 [default = false];
}

// Message that stores parameters shared by loss layers
// 存储有损耗层共享的消息结构
message LossParameter {
  // If specified, ignore instances with the given label.
  // 如果指定,忽略给定标签的实例
  optional int32 ignore_label = 1;
  // How to normalize the loss for loss layers that aggregate across batches,
  // spatial dimensions, or other dimensions.  Currently only implemented in
  // SoftmaxWithLoss layer.
  // 如何归一化在不同批次之间聚合的损失层的损失,空间尺寸或其他尺寸。
  // 目前仅实现了SoftmaxWithLoss层
  enum NormalizationMode {
    // Divide by the number of examples in the batch times spatial dimensions.
    // Outputs that receive the ignore label will NOT be ignored in computing
    // the normalization factor.
    // 除以例子中批次时域尺寸的数目
    // 接受的输出中忽略的标签将会考虑在计算归一化因子的过程中
    FULL = 0;
    // Divide by the total number of output locations that do not take the
    // ignore_label.  If ignore_label is not set, this behaves like FULL.
    // 除以未采用ignore_label的输出位置的总数。 如果未设置ignore_label,则其行为类似于FULL。
    VALID = 1;
    // Divide by the batch size.
    // 除以批尺寸
    BATCH_SIZE = 2;
    // Do not normalize the loss.
    // 不归一化
    NONE = 3;
  }
  optional NormalizationMode normalization = 3 [default = VALID];
  // Deprecated.  Ignored if normalization is specified.  If normalization
  // is not specified, then setting this to false will be equivalent to
  // normalization = BATCH_SIZE to be consistent with previous behavior.
  // 已弃用。 如果指定了归一化,则忽略。 如果未指定规范化,则将其设置为false,
  // 将等同于规范化= BATCH_SIZE,以与以前的行为一致。
  optional bool normalize = 2;
}

// Messages that store parameters used by individual layer types follow, in
// alphabetical order.

message AccuracyParameter {
  // When computing accuracy, count as correct by comparing the true label to
  // the top k scoring classes.  By default, only compare to the top scoring
  // class (i.e. argmax).
  // 当计算准确性时,通过将真实标签与前k个评分类进行比较来计算为正确。
  // 默认情况下,只比较顶级评分类(即argmax)。
  optional uint32 top_k = 1 [default = 1];

  // The "label" axis of the prediction blob, whose argmax corresponds to the
  // predicted label -- may be negative to index from the end (e.g., -1 for the
  // last axis).  For example, if axis == 1 and the predictions are
  // (N x C x H x W), the label blob is expected to contain N*H*W ground truth
  // labels with integer values in {0, 1, ..., C-1}.
  // 预测blob的“标签”轴(其argmax对应于预测标签)可以从末端开始索引(例如,对于最后一个轴为-1)。
  // 例如,如果axis == 1并且预测是(N×C×H×W),则期望标签blob包含具有{0,1,...,N}中的整数值}。
  optional int32 axis = 2 [default = 1];

  // If specified, ignore instances with the given label.
  // 如果指定,忽略给定标签的实例
  optional int32 ignore_label = 3;
}

message ArgMaxParameter {
  // If true produce pairs (argmax, maxval)
  // 如果为真,产生 (argmax, maxval)数据对,默认为假
  optional bool out_max_val = 1 [default = false];
  optional uint32 top_k = 2 [default = 1];
  // The axis along which to maximise -- may be negative to index from the
  // end (e.g., -1 for the last axis).
  // 沿其最大化的轴可以对从末端开始的索引为负(例如,对于最后一个轴为-1)。
  // By default ArgMaxLayer maximizes over the flattened trailing dimensions
  // for each index of the first / num dimension.
  // 默认情况下,ArgMaxLayer最大化第一个/num维度的每个索引的摊平尾部维度。
  optional int32 axis = 3;
}

message ConcatParameter {
  // The axis along which to concatenate -- may be negative to index from the
  // end (e.g., -1 for the last axis).  Other axes must have the
  // same dimension for all the bottom blobs.
  // By default, ConcatLayer concatenates blobs along the "channels" axis (1).
  // 沿着其连接的轴 - 可以从末尾开始索引(例如,对于最后一个轴为-1)。 其他轴必须有
  // 相同尺寸的所有底部斑点。
  // 默认情况下,ConcatLayer沿着“通道”轴(1)连接blob。
  optional int32 axis = 2 [default = 1];

  // DEPRECATED: alias for "axis" -- does not support negative indexing.
  // DEPRECATED:“axis”的别名 - 不支持负索引。
  optional uint32 concat_dim = 1 [default = 1];
}

message BatchNormParameter {
  // If false, accumulate global mean/variance values via a moving average. If
  // true, use those accumulated values instead of computing mean/variance
  // across the batch.
  // 如果为假,则通过移动平均值累积全局均值/方差值。
  // 如果为真,请使用这些累计值,而不是计算整个批次的均值/方差。
  optional bool use_global_stats = 1;
  // How much does the moving average decay each iteration?
  //每次迭代移动平均值衰减有多少?
  optional float moving_average_fraction = 2 [default = .999];
  // Small value to add to the variance estimate so that we don't divide by
  // zero.
  // 防止除0
  optional float eps = 3 [default = 1e-5];
}

message BiasParameter {
  // The first axis of bottom[0] (the first input Blob) along which to apply
  // bottom[1] (the second input Blob).  May be negative to index from the end
  // (e.g., -1 for the last axis).
  //
  // 底部[0]的第一个轴(第一个输入Blob),沿着它应用底部[1](第二个输入Blob)。
  // 可以从末尾开始索引(例如,对于最后一个轴为-1)。
  // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
  // top[0] will have the same shape, and bottom[1] may have any of the
  // following shapes (for the given value of axis):
  // 例如,如果底部[0]是具有形状100x3x40x60的4D,则为输出
  // 顶部[0]将具有相同的形状,底部[1]可具有任何的
  // 以下形状(对于给定的轴值):
  //    (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
  //    (axis == 1 == -3)          3;     3x40;     3x40x60
  //    (axis == 2 == -2)                   40;       40x60
  //    (axis == 3 == -1)                                60
  // Furthermore, bottom[1] may have the empty shape (regardless of the value of
  // "axis") -- a scalar bias.
  // 此外,底部[1]可以具有空形状(不管“轴”的值) - 标量偏差。
  optional int32 axis = 1 [default = 1];

  // (num_axes is ignored unless just one bottom is given and the bias is
  // a learned parameter of the layer.  Otherwise, num_axes is determined by the
  // number of axes by the second bottom.)
  // (忽略num_axes,除非给定一个底部,偏差是层的学习参数,否则num_axes由第二个底部的轴数确定)。
  // The number of axes of the input (bottom[0]) covered by the bias
  // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
  // Set num_axes := 0, to add a zero-axis Blob: a scalar.
  // 由偏置参数覆盖的输入(底部[0])的轴数,或从“轴”开始覆盖底部[0]的所有轴的-1。
  // 设置num_axes:= 0,以添加零轴Blob:标量。
  optional int32 num_axes = 2 [default = 1];

  // (filler is ignored unless just one bottom is given and the bias is
  // a learned parameter of the layer.)
  // The initialization for the learned bias parameter.
  // Default is the zero (0) initialization, resulting in the BiasLayer
  // initially performing the identity operation.
  // (填充被忽略,除非只给出一个底部,并且偏置是层的学习参数)。
  // 学习的偏置参数的初始化。
  // 默认是零(0)初始化,导致偏置层初始化执行识别操作。
  optional FillerParameter filler = 3;
}
message ContrastiveLossParameter {
  // margin for dissimilar pair
  optional float margin = 1 [default = 1.0];
  // The first implementation of this cost did not exactly match the cost of
  // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2.
  // legacy_version = false (the default) uses (margin - d)^2 as proposed in the
  // Hadsell paper. New models should probably use this version.
  // legacy_version = true uses (margin - d^2). This is kept to support /
  // reproduce existing models and results
  // 这个成本的第一个实现并不完全匹配的成本 Hadsell等人2006 - 使用(margin-d ^ 2)而不是(margin-d)^ 2。
  // legacy_version = false(默认)使用(margin-d)^ 2建议的 Hadsell文中。 新模型应该可以使用这个版本。
  // legacy_version = true uses(margin - d ^ 2)。 这保持支持/ 重现现有模型和结果
  optional bool legacy_version = 2 [default = false];
}

message ConvolutionParameter {
  optional uint32 num_output = 1; // The number of outputs for the layer
  optional bool bias_term = 2 [default = true]; // whether to have bias terms:是否含有偏置

  // Pad, kernel size, and stride are all given as a single value for equal
  // dimensions in all spatial dimensions, or once per spatial dimension.
  // 填充,内核大小和步幅都被给定为在所有空间维度中相等维度的单个值,或者每个空间维度一次。
  repeated uint32 pad = 3; // The padding size; defaults to 0
  repeated uint32 kernel_size = 4; // The kernel size
  repeated uint32 stride = 6; // The stride; defaults to 1
  // Factor used to dilate the kernel, (implicitly) zero-filling the resulting
  // holes. (Kernel dilation is sometimes referred to by its use in the
  // algorithme à trous from Holschneider et al. 1987.)
  // 用于膨胀内核的因子,(隐含地)填充所产生的孔。
  //(内核膨胀有时通过其在Holschneider等人1987的算法中的使用来指代)
  repeated uint32 dilation = 18; // The dilation; defaults to 1

  // For 2D convolution only, the *_h and *_w versions may also be used to
  // specify both spatial dimensions.
  // 仅针对2D卷积,*_h and *_w version也可以用作指定的时域维度
  optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only)
  optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only)
  optional uint32 kernel_h = 11; // The kernel height (2D only)
  optional uint32 kernel_w = 12; // The kernel width (2D only)
  optional uint32 stride_h = 13; // The stride height (2D only)
  optional uint32 stride_w = 14; // The stride width (2D only)

  optional uint32 group = 5 [default = 1]; // The group size for group conv

  optional FillerParameter weight_filler = 7; // The filler for the weight
  optional FillerParameter bias_filler = 8; // The filler for the bias
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 15 [default = DEFAULT];

  // The axis to interpret as "channels" when performing convolution.
  // Preceding dimensions are treated as independent inputs;
  // succeeding dimensions are treated as "spatial".
  // With (N, C, H, W) inputs, and axis == 1 (the default), we perform
  // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for
  // groups g>1) filters across the spatial axes (H, W) of the input.
  // With (N, C, D, H, W) inputs, and axis == 1, we perform
  // N independent 3D convolutions, sliding (C/g)-channels
  // filters across the spatial axes (D, H, W) of the input.
  // 执行卷积时解释为“通道”的轴。 先前维度被视为独立输入;后续维度被视为“空间”。
  //(N,C,H,W)输入和axis == 1(默认),我们执行N个独立的2D卷积,
  // 滑动C通道(或(C / g)通道,对于组g> 1)在输入的空间轴(H,W)上进行滤波。
  // 利用(N,C,D,H,W)输入和轴== 1,我们执行N个独立的3D卷积,在输入的空间轴(D,H,W)上滑动(C / g) 。
  optional int32 axis = 16 [default = 1];

  // Whether to force use of the general ND convolution, even if a specific
  // implementation for blobs of the appropriate number of spatial dimensions
  // is available. (Currently, there is only a 2D-specific convolution
  // implementation; for input blobs with num_axes != 2, this option is
  // ignored and the ND implementation will be used.)
  // 是否强制使用一般的ND卷积,即使可用具有适当数量的空间维度的blob的特定实现。
  // (目前,只有2D特定卷积实现;对于num_axes!= 2的输入blob,此选项被忽略,将使用ND实现)。
  optional bool force_nd_im2col = 17 [default = false];
}

message DataParameter {
  enum DB {
    LEVELDB = 0;
    LMDB = 1;
  }
  // Specify the data source. //指定数据源
  optional string source = 1;
  // Specify the batch size. //指定块尺寸
  optional uint32 batch_size = 4;
  // The rand_skip variable is for the data layer to skip a few data points
  // to avoid all asynchronous sgd clients to start at the same point. The skip
  // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
  // be larger than the number of keys in the database.
  // DEPRECATED. Each solver accesses a different subset of the database.
  // rand_skip变量用于数据层跳过几个数据点,以避免所有异步sgd客户端在同一点开始。
  // 跳过点将被设置为rand_skip*rand(0,1)。请注意,rand_skip不应该大于数据库中的键数。
  // 已过时。每个求解器访问数据库的不同子集。
  optional uint32 rand_skip = 7 [default = 0];
  optional DB backend = 8 [default = LEVELDB];
  // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
  // simple scaling and subtracting the data mean, if provided. Note that the
  // mean subtraction is always carried out before scaling.
  // 过时了。参见TransformationParameter。
  // 如果使用数据预处理,我们可以做一些简单的尺度化和对数据均值的减法。
  // 注意,减法操作在尺度化操作之前
  optional float scale = 2 [default = 1];
  optional string mean_file = 3;
  // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
  // crop an image.
  // 过时了,参见TransformationParameter。指定是否要随机裁剪图片。
  optional uint32 crop_size = 5 [default = 0];
  // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
  // data.
  // 过时了,参见TransformationParameter。指定是否要随机镜像(拷贝)数据。
  optional bool mirror = 6 [default = false];
  // Force the encoded image to have 3 color channels
  // 强制将图像编码成三通道颜色,默认设置为否
  optional bool force_encoded_color = 9 [default = false];
  // Prefetch queue (Number of batches to prefetch to host memory, increase if
  // data access bandwidth varies).
  // 预取队列(要预取到主机内存的批次数,如果数据访问带宽变化则增加)。
  optional uint32 prefetch = 10 [default = 4];
}

message DropoutParameter {
  optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio:衰减率,默认设置为0.5
  optional bool scale_train = 2 [default = true];  // scale train or test phase:尺度化训练或测试状态
}

// DummyDataLayer fills any number of arbitrarily shaped blobs with random
// (or constant) data generated by "Fillers" (see "message FillerParameter").
//  假数据层用随机填充任意数量的任意形状的斑点 (或常量)由“填充器”生成的数据(见“消息填充参数”)。
message DummyDataParameter {
  // This layer produces N >= 1 top blobs.  DummyDataParameter must specify 1 or N
  // shape fields, and 0, 1 or N data_fillers.
  // 该层产生N> = 1个顶部blob。 假数据层必须指定1或N形状字段,以及0,1或N data_fillers。
  // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used.
  // 如果数据填充器指定为0,使用值为0的常数填充器。
  // If 1 data_filler is specified, it is applied to all top blobs.  If N are
  // specified, the ith is applied to the ith top blob.
  // 如果数据填充器指定为1,应用所有的顶层blobs。
  // 如果数据填充器指定为N,i应用第i的顶层blobs
  repeated FillerParameter data_filler = 1;
  repeated BlobShape shape = 6;

  // 4D dimensions -- deprecated.  Use "shape" instead.
  repeated uint32 num = 2;
  repeated uint32 channels = 3;
  repeated uint32 height = 4;
  repeated uint32 width = 5;
}

message EltwiseParameter {
  enum EltwiseOp {
    PROD = 0;
    SUM = 1;
    MAX = 2;
  }
  optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation:元素操作
  repeated float coeff = 2; // blob-wise coefficient for SUM operation:用于SUM操作的blob系数

  // Whether to use an asymptotically slower (for >2 inputs) but stabler method
  // of computing the gradient for the PROD operation. (No effect for SUM op.)
  // 是否使用渐近较慢(用于> 2个输入),但是计算PROD操作的梯度的稳定方法。(SUM操作无效)
  optional bool stable_prod_grad = 3 [default = true];
}

// Message that stores parameters used by ELULayer
message ELUParameter {
  // Described in:
  // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate
  // Deep Network Learning by Exponential Linear Units (ELUs). arXiv
  optional float alpha = 1 [default = 1];
}

// Message that stores parameters used by EmbedLayer
// 被用作嵌入层的存储参数的消息结构
message EmbedParameter {
  optional uint32 num_output = 1; // The number of outputs for the layer
  // The input is given as integers to be interpreted as one-hot
  // vector indices with dimension num_input.  Hence num_input should be
  // 1 greater than the maximum possible input value.
  // 输入作为整数给出,以被解释为具有num_input维的一热矢量索引。
  // 因此数值输入应该大于最大可能输入值的1。
  optional uint32 input_dim = 2;

  optional bool bias_term = 3 [default = true]; // Whether to use a bias term
  optional FillerParameter weight_filler = 4; // The filler for the weight
  optional FillerParameter bias_filler = 5; // The filler for the bias

}

// Message that stores parameters used by ExpLayer
// 被用作指数层的存储参数的消息结构
message ExpParameter {
  // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0.
  // Or if base is set to the default (-1), base is set to e,
  // so y = exp(shift + scale * x).
  optional float base = 1 [default = -1.0];
  optional float scale = 2 [default = 1.0];
  optional float shift = 3 [default = 0.0];
}

/// Message that stores parameters used by FlattenLayer
/// 被用作打散层的存储参数的消息结构
message FlattenParameter {
  // The first axis to flatten: all preceding axes are retained in the output.
  // May be negative to index from the end (e.g., -1 for the last axis).
  optional int32 axis = 1 [default = 1];
  // 第一轴展平:所有前面的轴都保留在输出中。
  // 可以从末尾开始索引(例如,对于最后一个轴为-1)。

  // The last axis to flatten: all following axes are retained in the output.
  // May be negative to index from the end (e.g., the default -1 for the last
  // axis).
  optional int32 end_axis = 2 [default = -1];
}

// Message that stores parameters used by HDF5DataLayer
// 被用作HDF5数据层的存储参数的消息结构
message HDF5DataParameter {
  // Specify the data source.
  optional string source = 1;
  // Specify the batch size.
  optional uint32 batch_size = 2;

  // Specify whether to shuffle the data.
  // If shuffle == true, the ordering of the HDF5 files is shuffled,
  // and the ordering of data within any given HDF5 file is shuffled,
  // but data between different files are not interleaved; all of a file's
  // data are output (in a random order) before moving onto another file.
  // 如果shuffle == true,则HDF5文件的顺序被打乱,并且任何给定HDF5文件内的数据的顺序被打乱,
  // 但是不同文件之间的数据不交错; 所有文件的数据在移动到另一个文件之前被输出(以随机顺序)。
  optional bool shuffle = 3 [default = false];
}

message HDF5OutputParameter {
  optional string file_name = 1;
}

message HingeLossParameter {
  enum Norm {
    L1 = 1;
    L2 = 2;
  }
  // Specify the Norm to use L1 or L2
  // 指定正则化为L1或者L2,默认为L1
  optional Norm norm = 1 [default = L1];
}

message ImageDataParameter {
  // Specify the data source.
  optional string source = 1;
  // Specify the batch size.
  optional uint32 batch_size = 4 [default = 1];
  // The rand_skip variable is for the data layer to skip a few data points
  // to avoid all asynchronous sgd clients to start at the same point. The skip
  // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
  // be larger than the number of keys in the database.
  optional uint32 rand_skip = 7 [default = 0];
  // Whether or not ImageLayer should shuffle the list of files at every epoch.
  // 是否图像层应该在每个时期打乱文件列表。默认不打乱
  optional bool shuffle = 8 [default = false];
  // It will also resize images if new_height or new_width are not zero.
  // 如果图像新的高度和宽度不是零,那么更改图像尺寸
  optional uint32 new_height = 9 [default = 0];
  optional uint32 new_width = 10 [default = 0];
  // Specify if the images are color or gray
  // 指定图像是彩色的还是灰度的
  optional bool is_color = 11 [default = true];
  // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
  // simple scaling and subtracting the data mean, if provided. Note that the
  // mean subtraction is always carried out before scaling.
  optional float scale = 2 [default = 1];
  optional string mean_file = 3;
  // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
  // crop an image.
  optional uint32 crop_size = 5 [default = 0];
  // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
  // data.
  optional bool mirror = 6 [default = false];
  optional string root_folder = 12 [default = ""];
}

message InfogainLossParameter {
  // Specify the infogain matrix source.
  // 指定 infogain的矩阵数据源
  optional string source = 1;
}

message InnerProductParameter {
  optional uint32 num_output = 1; // The number of outputs for the layer
  optional bool bias_term = 2 [default = true]; // whether to have bias terms
  optional FillerParameter weight_filler = 3; // The filler for the weight
  optional FillerParameter bias_filler = 4; // The filler for the bias

  // The first axis to be lumped into a single inner product computation;
  // all preceding axes are retained in the output.
  // 第一个轴要集中到单个内积计算中;所有前面的轴都保留在输出中。
  // May be negative to index from the end (e.g., -1 for the last axis).
  optional int32 axis = 5 [default = 1];
}

// Message that stores parameters used by LogLayer
//   被用作对数层的存储参数的消息结构
message LogParameter {
  // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0.
  // Or if base is set to the default (-1), base is set to e,
  // so y = ln(shift + scale * x) = log_e(shift + scale * x)
  optional float base = 1 [default = -1.0];
  optional float scale = 2 [default = 1.0];
  optional float shift = 3 [default = 0.0];
}

// Message that stores parameters used by LRNLayer
//   被用作LRN层的存储参数的消息结构
message LRNParameter {
  optional uint32 local_size = 1 [default = 5];
  optional float alpha = 2 [default = 1.];
  optional float beta = 3 [default = 0.75];
  enum NormRegion {
    ACROSS_CHANNELS = 0;
    WITHIN_CHANNEL = 1;
  }
  optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
  optional float k = 5 [default = 1.];
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 6 [default = DEFAULT];
}

message MemoryDataParameter {
  optional uint32 batch_size = 1;
  optional uint32 channels = 2;
  optional uint32 height = 3;
  optional uint32 width = 4;
}

message MVNParameter {
  // This parameter can be set to false to normalize mean only
  // 此参数可以设置为假以仅对平均值进行标准化
  optional bool normalize_variance = 1 [default = true];

  // This parameter can be set to true to perform DNN-like MVN
  // 此参数可以设置为真对类似DNN的MVN
  optional bool across_channels = 2 [default = false];

  // Epsilon for not dividing by zero while normalizing variance
  optional float eps = 3 [default = 1e-9];
}

message PoolingParameter {
  enum PoolMethod {
    MAX = 0; //最大值
    AVE = 1; // 平均值
    STOCHASTIC = 2;// 随机
  }
  optional PoolMethod pool = 1 [default = MAX]; // The pooling method
  // Pad, kernel size, and stride are all given as a single value for equal
  // dimensions in height and width or as Y, X pairs.
  optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X)
  optional uint32 pad_h = 9 [default = 0]; // The padding height:填充
  optional uint32 pad_w = 10 [default = 0]; // The padding width
  optional uint32 kernel_size = 2; // The kernel size (square)
  optional uint32 kernel_h = 5; // The kernel height:内核
  optional uint32 kernel_w = 6; // The kernel width
  optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X)
  optional uint32 stride_h = 7; // The stride height:步进
  optional uint32 stride_w = 8; // The stride width
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 11 [default = DEFAULT];
  // If global_pooling then it will pool over the size of the bottom by doing
  // kernel_h = bottom->height and kernel_w = bottom->width
  // 如果全局池化那么它将通过做池底部的大小
  // kernel_h = bottom-> height,kernel_w = bottom-> width
  optional bool global_pooling = 12 [default = false];
}

message PowerParameter {
  // PowerLayer computes outputs y = (shift + scale * x) ^ power.
  optional float power = 1 [default = 1.0];
  optional float scale = 2 [default = 1.0];
  optional float shift = 3 [default = 0.0];
}

message PythonParameter {
  optional string module = 1;
  optional string layer = 2;
  // This value is set to the attribute `param_str` of the `PythonLayer` object
  // in Python before calling the `setup()` method. This could be a number,
  // string, dictionary in Python dict format, JSON, etc. You may parse this
  // string in `setup` method and use it in `forward` and `backward`.
  // 该值设置为`PythonLayer`对象的`param_str`属性
  // 在Python中调用`setup()`方法。 这可能是一个数字,
  // 字符串,Python dict格式的字典,JSON等。你可以解析这个
  // 字符串在`setup`方法中,并在`forward`和`backward`中使用它。
  optional string param_str = 3 [default = ''];
  // Whether this PythonLayer is shared among worker solvers during data parallelism.
  // If true, each worker solver sequentially run forward from this layer.
  // This value should be set true if you are using it as a data layer.
  // 在数据并行期间,这个Python层是否在工作者解算器之间共享。
  // 如果为真,则每个工作解算器从该层顺序地向前运行。
  // 如果将其用作数据层,则此值应设置为真。
  optional bool share_in_parallel = 4 [default = false];
}

// Message that stores parameters used by ReductionLayer
//   被用作减少层的存储参数的消息结构
message ReductionParameter {
  enum ReductionOp {
    SUM = 1;
    ASUM = 2;
    SUMSQ = 3;
    MEAN = 4;
  }

  optional ReductionOp operation = 1 [default = SUM]; // reduction operation

  // The first axis to reduce to a scalar -- may be negative to index from the
  // end (e.g., -1 for the last axis).
  // (Currently, only reduction along ALL "tail" axes is supported; reduction
  // of axis M through N, where N < num_axes - 1, is unsupported.)
  // Suppose we have an n-axis bottom Blob with shape:
  //     (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)).
  // 减小到标量的第一轴 - 可以从端部索引为负(例如,对于最后一个轴为-1)。
  // (目前,仅支持沿着所有“尾”轴的缩减;轴M到N的缩减,其中N <num_axes-1不被支持)
  // 假设我们有一个n轴底部Blob形状:
  // (d0,d1,d2,...,d(m-1),dm,d(m + 1),...,d(n-1))。
  // If axis == m, the output Blob will have shape
  //     (d0, d1, d2, ..., d(m-1)),
  // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1))
  // times, each including (dm * d(m+1) * ... * d(n-1)) individual data.
  // If axis == 0 (the default), the output Blob always has the empty shape
  // (count 1), performing reduction across the entire input --
  // often useful for creating new loss functions.
  // 如果axis == m,则输出Blob将具有形状(d0,d1,d2,...,d(m-1)),
  // 并执行reduceOp操作(d0 * d1 * d2 * ... * d(m-1))
  // 每个包括(dm * d(m + 1)* ... * d(n-1))个体数据。
  // 如果axis == 0(默认值),输出Blob总是具有空的形状
  // (计数1),在整个输入执行减少 - 通常用于创建新的损失函数
  optional int32 axis = 2 [default = 0];

  optional float coeff = 3 [default = 1.0]; // coefficient for output
}

// Message that stores parameters used by ReLULayer
// 被用作ReLU层的存储参数的消息结构
message ReLUParameter {
  // Allow non-zero slope for negative inputs to speed up optimization
  // 对负输入允许非零斜率以加速优化,在下面这篇文章中描述
  // Described in:
  // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities
  // improve neural network acoustic models. In ICML Workshop on Deep Learning
  // for Audio, Speech, and Language Processing.
  optional float negative_slope = 1 [default = 0];
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 2 [default = DEFAULT];
}

message ReshapeParameter {
  // Specify the output dimensions. If some of the dimensions are set to 0,
  // the corresponding dimension from the bottom layer is used (unchanged).
  // Exactly one dimension may be set to -1, in which case its value is
  // inferred from the count of the bottom blob and the remaining dimensions.
  // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8:
  // 指定输出尺寸。 如果某些维度设置为0, 使用来自底层的相应尺寸(不变)。
  // 正好一个维度可以设置为-1,在这种情况下,其值为
  // 从底部斑点的数量和剩余尺寸推断。 例如,假设我们想用形状2×8重塑二维块“输入”:
  //   layer {
  //     type: "Reshape" bottom: "input" top: "output"
  //     reshape_param { ... }
  //   }
  //
  // If "input" is 2D with shape 2 x 8, then the following reshape_param
  // specifications are all equivalent, producing a 3D blob "output" with shape
  // 2 x 2 x 4:
  // 如果输入2D信息为 2 x 8,那么以下reshape_param规范都是等效的,
  // 从而产生具有形状的3D团块“输出”  2×2×4:
  //
  //   reshape_param { shape { dim:  2  dim: 2  dim:  4 } }
  //   reshape_param { shape { dim:  0  dim: 2  dim:  4 } }
  //   reshape_param { shape { dim:  0  dim: 2  dim: -1 } }
  //   reshape_param { shape { dim: -1  dim: 0  dim:  2 } }
  //
  optional BlobShape shape = 1;

  // axis and num_axes control the portion of the bottom blob's shape that are
  // replaced by (included in) the reshape. By default (axis == 0 and
  // num_axes == -1), the entire bottom blob shape is included in the reshape,
  // and hence the shape field must specify the entire output shape.
  // axis和num_axes控制底部blob的形状的部分 替换为(包含)重塑。 默认情况下(axis == 0和
  // num_axes == -1),整个底部斑点形状包括在重塑中, 因此形状字段必须指定整个输出形状。
  // axis may be non-zero to retain some portion of the beginning of the input
  // shape (and may be negative to index from the end; e.g., -1 to begin the
  // reshape after the last axis, including nothing in the reshape,
  // -2 to include only the last axis, etc.).
  // 轴可以是非零的,以保留输入的开始的一些部分 形状(并且可以从末端索引为负;例如,-1开始
  // 在最后一个轴后重塑,包括没有什么在重塑, -2仅包括最后一个轴等)。
  //
  // For example, suppose "input" is a 2D blob with shape 2 x 8.
  // Then the following ReshapeLayer specifications are all equivalent,
  // producing a blob "output" with shape 2 x 2 x 4:
  //
  //   reshape_param { shape { dim: 2  dim: 2  dim: 4 } }
  //   reshape_param { shape { dim: 2  dim: 4 } axis:  1 }
  //   reshape_param { shape { dim: 2  dim: 4 } axis: -3 }
  //
  // num_axes specifies the extent of the reshape.
  // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on
  // input axes in the range [axis, axis+num_axes].
  // num_axes may also be -1, the default, to include all remaining axes
  // (starting from axis).
  // num_axes指定重塑的范围。 如果num_axes> = 0(且轴> = 0),则将仅执行reshape
  // 输入轴在[axis,axis + num_axes]范围内。 num_axes也可以是默认值-1,以包括所有其余轴 (从轴开始)。
  //
  // For example, suppose "input" is a 2D blob with shape 2 x 8.
  // Then the following ReshapeLayer specifications are equivalent,
  // producing a blob "output" with shape 1 x 2 x 8.
  //
  //   reshape_param { shape { dim:  1  dim: 2  dim:  8 } }
  //   reshape_param { shape { dim:  1  dim: 2  }  num_axes: 1 }
  //   reshape_param { shape { dim:  1  }  num_axes: 0 }
  //
  // On the other hand, these would produce output blob shape 2 x 1 x 8:
  //
  //   reshape_param { shape { dim: 2  dim: 1  dim: 8  }  }
  //   reshape_param { shape { dim: 1 }  axis: 1  num_axes: 0 }
  //
  optional int32 axis = 2 [default = 0];
  optional int32 num_axes = 3 [default = -1];
}

// Message that stores parameters used by ROIPoolingLayer
// 被用作ROI池化层的存储参数的消息结构
message ROIPoolingParameter {
  // Pad, kernel size, and stride are all given as a single value for equal
  // dimensions in height and width or as Y, X pairs.
  optional uint32 pooled_h = 1 [default = 0]; // The pooled output height
  optional uint32 pooled_w = 2 [default = 0]; // The pooled output width
  // Multiplicative spatial scale factor to translate ROI coords from their
  // input scale to the scale used when pooling
  // 乘法空间比例因子,用于将ROI坐标从其输入量表转换为合并时使用的量表
  optional float spatial_scale = 3 [default = 1];
}

message ScaleParameter {
  // The first axis of bottom[0] (the first input Blob) along which to apply
  // bottom[1] (the second input Blob).  May be negative to index from the end
  // (e.g., -1 for the last axis).
  //
  // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
  // top[0] will have the same shape, and bottom[1] may have any of the
  // following shapes (for the given value of axis):
  //    (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
  //    (axis == 1 == -3)          3;     3x40;     3x40x60
  //    (axis == 2 == -2)                   40;       40x60
  //    (axis == 3 == -1)                                60
  // Furthermore, bottom[1] may have the empty shape (regardless of the value of
  // "axis") -- a scalar multiplier.
  optional int32 axis = 1 [default = 1];

  // (num_axes is ignored unless just one bottom is given and the scale is
  // a learned parameter of the layer.  Otherwise, num_axes is determined by the
  // number of axes by the second bottom.)
  // (忽略num_axes,除非只给出一个底部,并且比例为 该层的学习参数。 否则,num_axes由
  // 轴的数量由第二个底部决定。)
  // The number of axes of the input (bottom[0]) covered by the scale
  // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
  // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar.
  // 由数轴的输入( bottom[0])的尺度参数覆盖,或-1覆盖从`axis`开始的底部[0]的所有轴。
  // 设置num_axes为0,乘以零轴Blob(一个标量)。
  optional int32 num_axes = 2 [default = 1];

  // (filler is ignored unless just one bottom is given and the scale is
  // a learned parameter of the layer.)
  // 仅有一个bottom的时候填充被忽略,尺度就是该层的学习参数
  // The initialization for the learned scale parameter.
  // 学习尺度参数的初始化.
  // Default is the unit (1) initialization, resulting in the ScaleLayer
  // initially performing the identity operation.
  // 默认单元(1)初始化,从而在尺度层初始化执行单位操作。
  optional FillerParameter filler = 3;

  // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but
  // may be more efficient).  Initialized with bias_filler (defaults to 0).
  optional bool bias_term = 4 [default = false];
  optional FillerParameter bias_filler = 5;
}

message SigmoidParameter {
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 1 [default = DEFAULT];
}

message SmoothL1LossParameter {
  // SmoothL1Loss(x) =
  //   0.5 * (sigma * x) ** 2    -- if x < 1.0 / sigma / sigma
  //   |x| - 0.5 / sigma / sigma -- otherwise
  optional float sigma = 1 [default = 1];
}

message SliceParameter {
  // The axis along which to slice -- may be negative to index from the end
  // (e.g., -1 for the last axis).
  // By default, SliceLayer concatenates blobs along the "channels" axis (1).
  optional int32 axis = 3 [default = 1];
  repeated uint32 slice_point = 2;

  // DEPRECATED: alias for "axis" -- does not support negative indexing.
  optional uint32 slice_dim = 1 [default = 1];
}

// Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer
// 被用作Softmax,SoftmaxWithLoss层的存储参数的消息结构
message SoftmaxParameter {
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 1 [default = DEFAULT];

  // The axis along which to perform the softmax -- may be negative to index
  // from the end (e.g., -1 for the last axis).
  // 跟着softmax的主轴执行,可能是负数,如果是负数,则为逆序索引
  // Any other axes will be evaluated as independent softmaxes.
  // 其他任何轴被评为softmax的独立值
  optional int32 axis = 2 [default = 1];
}

message TanHParameter {
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 1 [default = DEFAULT];
}

// Message that stores parameters used by TileLayer
// 被用作TileLayer层的存储参数的消息结构
message TileParameter {
  // The index of the axis to tile.
  optional int32 axis = 1 [default = 1];

  // The number of copies (tiles) of the blob to output.
  optional int32 tiles = 2;
}

// Message that stores parameters used by ThresholdLayer
// 被用作阈值化层的存储参数的消息结构
message ThresholdParameter {
  optional float threshold = 1 [default = 0]; // Strictly positive values //必须为正数
}

message WindowDataParameter {
  // Specify the data source.//指定数据源
  optional string source = 1; //源名
  // For data pre-processing, we can do simple scaling and subtracting the
  // data mean, if provided. Note that the mean subtraction is always carried
  // out before scaling.
  optional float scale = 2 [default = 1];//尺度
  optional string mean_file = 3;//均值文件
  // Specify the batch size.
  optional uint32 batch_size = 4;//块文件
  // Specify if we would like to randomly crop an image.//是否指定随机剪裁图像
  optional uint32 crop_size = 5 [default = 0];//剪裁尺寸
  // Specify if we want to randomly mirror data.//是否指定随机镜像图像
  optional bool mirror = 6 [default = false];//默认不镜像
  // Foreground (object) overlap threshold //前景(对象)重叠阈值
  optional float fg_threshold = 7 [default = 0.5];//默认0.5
  // Background (non-object) overlap threshold//背景(对象)重叠阈值
  optional float bg_threshold = 8 [default = 0.5];//默认0.5
  // Fraction of batch that should be foreground objects//块的一部分可能是前景一部分
  optional float fg_fraction = 9 [default = 0.25];//默认值为0.25
  // Amount of contextual padding to add around a window
  // 在窗口周围上文添加量
  // (used only by the window_data_layer) //仅用作窗口数据层
  optional uint32 context_pad = 10 [default = 0];
  // Mode for cropping out a detection window
  // 剪裁检测窗口的模式
  // warp: cropped window is warped to a fixed size and aspect ratio
  // 拉伸:将窗口拉伸到固定尺寸和纵横比大小
  // square: the tightest square around the window is cropped
  // 方形:按照窗口的最小矩形选定大小
  optional string crop_mode = 11 [default = "warp"]; //默认为“warp” 模式
  // cache_images: will load all images in memory for faster access
  // 缓存图片:将所有图片导入到内存中用来加快访问速度
  optional bool cache_images = 12 [default = false];
  // append root_folder to locate images
  // 添加根目录路径以查找图片
  optional string root_folder = 13 [default = ""];
}

message SPPParameter {
  enum PoolMethod {
    MAX = 0;
    AVE = 1;
    STOCHASTIC = 2;
  }
  optional uint32 pyramid_height = 1;
  optional PoolMethod pool = 2 [default = MAX]; // The pooling method //池化方法:最大值
  enum Engine {
    DEFAULT = 0;
    CAFFE = 1;
    CUDNN = 2;
  }
  optional Engine engine = 6 [default = DEFAULT];
}

// DEPRECATED: use LayerParameter.
message V1LayerParameter {
  repeated string bottom = 2;
  repeated string top = 3;
  optional string name = 4;
  repeated NetStateRule include = 32;
  repeated NetStateRule exclude = 33;
  enum LayerType {
    NONE = 0;
    ABSVAL = 35;
    ACCURACY = 1;
    ARGMAX = 30;
    BNLL = 2;
    CONCAT = 3;
    CONTRASTIVE_LOSS = 37;
    CONVOLUTION = 4;
    DATA = 5;
    DECONVOLUTION = 39;
    DROPOUT = 6;
    DUMMY_DATA = 32;
    EUCLIDEAN_LOSS = 7;
    ELTWISE = 25;
    EXP = 38;
    FLATTEN = 8;
    HDF5_DATA = 9;
    HDF5_OUTPUT = 10;
    HINGE_LOSS = 28;
    IM2COL = 11;
    IMAGE_DATA = 12;
    INFOGAIN_LOSS = 13;
    INNER_PRODUCT = 14;
    LRN = 15;
    MEMORY_DATA = 29;
    MULTINOMIAL_LOGISTIC_LOSS = 16;
    MVN = 34;
    POOLING = 17;
    POWER = 26;
    RELU = 18;
    SIGMOID = 19;
    SIGMOID_CROSS_ENTROPY_LOSS = 27;
    SILENCE = 36;
    SOFTMAX = 20;
    SOFTMAX_LOSS = 21;
    SPLIT = 22;
    SLICE = 33;
    TANH = 23;
    WINDOW_DATA = 24;
    THRESHOLD = 31;
  }
  optional LayerType type = 5;
  repeated BlobProto blobs = 6;
  repeated string param = 1001;
  repeated DimCheckMode blob_share_mode = 1002;
  enum DimCheckMode {
    STRICT = 0;
    PERMISSIVE = 1;
  }
  repeated float blobs_lr = 7;
  repeated float weight_decay = 8;
  repeated float loss_weight = 35;
  optional AccuracyParameter accuracy_param = 27;
  optional ArgMaxParameter argmax_param = 23;
  optional ConcatParameter concat_param = 9;
  optional ContrastiveLossParameter contrastive_loss_param = 40;
  optional ConvolutionParameter convolution_param = 10;
  optional DataParameter data_param = 11;
  optional DropoutParameter dropout_param = 12;
  optional DummyDataParameter dummy_data_param = 26;
  optional EltwiseParameter eltwise_param = 24;
  optional ExpParameter exp_param = 41;
  optional HDF5DataParameter hdf5_data_param = 13;
  optional HDF5OutputParameter hdf5_output_param = 14;
  optional HingeLossParameter hinge_loss_param = 29;
  optional ImageDataParameter image_data_param = 15;
  optional InfogainLossParameter infogain_loss_param = 16;
  optional InnerProductParameter inner_product_param = 17;
  optional LRNParameter lrn_param = 18;
  optional MemoryDataParameter memory_data_param = 22;
  optional MVNParameter mvn_param = 34;
  optional PoolingParameter pooling_param = 19;
  optional PowerParameter power_param = 21;
  optional ReLUParameter relu_param = 30;
  optional SigmoidParameter sigmoid_param = 38;
  optional SoftmaxParameter softmax_param = 39;
  optional SliceParameter slice_param = 31;
  optional TanHParameter tanh_param = 37;
  optional ThresholdParameter threshold_param = 25;
  optional WindowDataParameter window_data_param = 20;
  optional TransformationParameter transform_param = 36;
  optional LossParameter loss_param = 42;
  optional V0LayerParameter layer = 1;
}

// DEPRECATED: V0LayerParameter is the old way of specifying layer parameters
// in Caffe.  We keep this message type around for legacy support.
//  舍弃:V0LayerParameter参数是Caffe中指定层参数的旧方式。此处保留是为了向下兼容考虑。
message V0LayerParameter {
  optional string name = 1; // the layer name
  optional string type = 2; // the string to specify the layer type

  // Parameters to specify layers with inner products.
  // 指定层与层之间内积参数
  optional uint32 num_output = 3; // The number of outputs for the layer
  optional bool biasterm = 4 [default = true]; // whether to have bias terms
  optional FillerParameter weight_filler = 5; // The filler for the weight
  optional FillerParameter bias_filler = 6; // The filler for the bias

  optional uint32 pad = 7 [default = 0]; // The padding size
  optional uint32 kernelsize = 8; // The kernel size
  optional uint32 group = 9 [default = 1]; // The group size for group conv
  optional uint32 stride = 10 [default = 1]; // The stride
  enum PoolMethod {
    MAX = 0;
    AVE = 1;
    STOCHASTIC = 2;
  }
  optional PoolMethod pool = 11 [default = MAX]; // The pooling method
  optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio //默认衰减因子0.5

  optional uint32 local_size = 13 [default = 5]; // for local response norm//默认局部尺寸5
  optional float alpha = 14 [default = 1.]; // for local response norm//alpha = 1
  optional float beta = 15 [default = 0.75]; // for local response norm//beta = 0.75
  optional float k = 22 [default = 1.];// k = 1

  // For data layers, specify the data source
  optional string source = 16;
  // For data pre-processing, we can do simple scaling and subtracting the
  // data mean, if provided. Note that the mean subtraction is always carried
  // out before scaling.
  optional float scale = 17 [default = 1];
  optional string meanfile = 18;
  // For data layers, specify the batch size.
  optional uint32 batchsize = 19;
  // For data layers, specify if we would like to randomly crop an image.
  optional uint32 cropsize = 20 [default = 0];
  // For data layers, specify if we want to randomly mirror data.
  optional bool mirror = 21 [default = false];

  // The blobs containing the numeric parameters of the layer
  repeated BlobProto blobs = 50;
  // The ratio that is multiplied on the global learning rate. If you want to
  // set the learning ratio for one blob, you need to set it for all blobs.
  repeated float blobs_lr = 51;
  // The weight decay that is multiplied on the global weight decay.
  repeated float weight_decay = 52;

  // The rand_skip variable is for the data layer to skip a few data points
  // to avoid all asynchronous sgd clients to start at the same point. The skip
  // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
  // be larger than the number of keys in the database.
  // rand_skip变量用于数据层跳过几个数据点
  // 以避免所有异步sgd客户端在同一点启动。 跳过
  // 点将被设置为rand_skip * rand(0,1)。 请注意,rand_skip不应该
  // 大于数据库中的关键点数。
  optional uint32 rand_skip = 53 [default = 0];

  // Fields related to detection (det_*)
  // foreground (object) overlap threshold // 前景重叠阈值
  optional float det_fg_threshold = 54 [default = 0.5];
  // background (non-object) overlap threshold // 背景重叠阈值
  optional float det_bg_threshold = 55 [default = 0.5];
  // Fraction of batch that should be foreground objects
  // 图像块组的部分应该前景的概率,默认值为0.25
  optional float det_fg_fraction = 56 [default = 0.25];

  // optional bool OBSOLETE_can_clobber = 57 [default = true];

  // Amount of contextual padding to add around a window
  // 在窗口周围添加的上下填充量,仅被用作窗口数据层
  // (used only by the window_data_layer)
  optional uint32 det_context_pad = 58 [default = 0];

  // Mode for cropping out a detection window
  // warp: cropped window is warped to a fixed size and aspect ratio
  // square: the tightest square around the window is cropped
  optional string det_crop_mode = 59 [default = "warp"];

  // For ReshapeLayer, one needs to specify the new dimensions.
  // 对于Reshape层,需要指定新维度。
  optional int32 new_num = 60 [default = 0];
  optional int32 new_channels = 61 [default = 0];
  optional int32 new_height = 62 [default = 0];
  optional int32 new_width = 63 [default = 0];

  // Whether or not ImageLayer should shuffle the list of files at every epoch.
  // It will also resize images if new_height or new_width are not zero.
  // 图像层是否应该在每个时期打乱文件列表
  // 如果新的宽度和高度不为零,那么图像将会重新指定尺寸
  optional bool shuffle_images = 64 [default = false];

  // For ConcatLayer, one needs to specify the dimension for concatenation, and
  // the other dimensions must be the same for all the bottom blobs.
  // By default it will concatenate blobs along the channels dimension.
  // 对于ConcatLayer,需要指定用于级联的维度
  // 所有底部斑点的其他尺寸必须相同。
  // 默认情况下,它将沿通道维度连接blob。
  optional uint32 concat_dim = 65 [default = 1];

  optional HDF5OutputParameter hdf5_output_param = 1001;
}

message PReLUParameter {
  // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers:
  // Surpassing Human-Level Performance on ImageNet Classification, 2015.
  // 参数ReLU出自于Delving Deep into Rectifiers:Surpassing Human-Level Performance
  // on ImageNet Classification文章

  // Initial value of a_i. Default is a_i=0.25 for all i.
  // a_i的初始值,默认为0.25
  optional FillerParameter filler = 1;
  // Whether or not slope paramters are shared across channels.
  // 是否跨通道共享斜率参数
  optional bool channel_shared = 2 [default = false];
}

猜你喜欢

转载自blog.csdn.net/weixin_39970417/article/details/80824671
今日推荐