Layer是caffe 基本计算单元, 至少有一个输入Blob(Bottom) 和输出Blob(Top), 部分layer带有weight 和bias项.
两个运算方向:前向传播和反向传播.
相关数据结构,位于caffe.proto中的LayerParameter部分:
(当增加新的LayerParameter域时,要更新下一个可用ID, 这在自定义层时会用到.)
// NOTE
// Update the next available ID when you add a new LayerParameter field.
//
// LayerParameter next available layer-specific ID: 147 (last added: recurrent_param)
//当增加新的LayerParameter域时,要更新下一个可用ID, 这在自定义层时会用到.
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
optional Phase phase = 10; //当前阶段(train or test)
//为每个Top Blob 分配对损失函数的权重,每个layer都有默认值,0不参与计算,1参与计算.
repeated float loss_weight = 5;
repeated ParamSpec param = 6; //指定训练参数
repeated BlobProto blobs = 7; //承载了该层数值参数的blob
// The size must be either 0 or equal to the number of bottoms.
repeated bool propagate_down = 11;//是否对Bottom Blob进行反向传播,该字段维度要与Bottom Blob个数一致
//控制某个层在某个时刻是否包含在网络中
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.
//特定类型层的参数
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 CropParameter crop_param = 144;
optional DataParameter data_param = 107;
optional DropoutParameter dropout_param = 108;
optional DummyDataParameter dummy_data_param = 109;
optional EltwiseParameter eltwise_param = 110;
optional ELUParameter elu_param = 140;
optional EmbedParameter embed_param = 137;
optional ExpParameter exp_param = 111;
optional FlattenParameter flatten_param = 135;
optional HDF5DataParameter hdf5_data_param = 112;
optional HDF5OutputParameter hdf5_output_param = 113;
optional HingeLossParameter hinge_loss_param = 114;
optional ImageDataParameter image_data_param = 115;
optional InfogainLossParameter infogain_loss_param = 116;
optional InnerProductParameter inner_product_param = 117;
optional InputParameter input_param = 143;
optional LogParameter log_param = 134;
optional LRNParameter lrn_param = 118;
optional MemoryDataParameter memory_data_param = 119;
optional MVNParameter mvn_param = 120;
optional ParameterParameter parameter_param = 145;
optional PoolingParameter pooling_param = 121;
optional PowerParameter power_param = 122;
optional PReLUParameter prelu_param = 131;
optional PythonParameter python_param = 130;
optional RecurrentParameter recurrent_param = 146;
optional ReductionParameter reduction_param = 136;
optional ReLUParameter relu_param = 123;
optional ReshapeParameter reshape_param = 133;
optional ScaleParameter scale_param = 142;
optional SigmoidParameter sigmoid_param = 124;
optional SoftmaxParameter softmax_param = 125;
optional SPPParameter spp_param = 132;
optional SliceParameter slice_param = 126;
optional TanHParameter tanh_param = 127;
optional ThresholdParameter threshold_param = 128;
optional TilePa