Caffe Prototxt层系列:Convolution Layer

版权声明:未经博主允许,不得转载! https://blog.csdn.net/u011681952/article/details/86157060

Convolution Layer是CNN中最常见最重要的特征提取层,形式多种多样

首先我们先看一下 InnerProductParameter

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  是否使用bias项
	
	  // 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.)
	  repeated uint32 dilation = 18; // The dilation; defaults to 1       空洞大小  默认1(空洞卷积中常用,如某些语义分割网络)
	
	  // For 2D convolution only, the *_h and *_w versions may also be used to
	  // specify both spatial dimensions.
	  //2D卷积,当高宽不一致时,常常用下列参数
	  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)  y轴步幅
	  optional uint32 stride_w = 14; // The stride width (2D only)  x轴步幅
	
	  optional uint32 group = 5 [default = 1]; // The group size for group conv   组卷积 默认1    实例见shufflenet
	
	  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.
	  optional int32 axis = 16 [default = 1];     卷积轴,默认通道(3D卷积中,有时序轴卷积情况)
	
	  // 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];
}

卷积形式太多,一时难以收集全,先举个例子,以后慢慢更新
例如在MobileNet中:

layer {
	  name: "conv6_3/dwise"
	  type: "Convolution"
	  bottom: "conv6_3/expand/bn"
	  top: "conv6_3/dwise"
	  param {
		    lr_mult: 1        
		    decay_mult: 1  
	  }
	  convolution_param {
		    num_output: 960     //输出个数
		    bias_term: false     //不使用bias项
		    pad: 1   //填充1个像素
		    kernel_size: 3   //卷积核大小3*3
		    group: 960   //组个数    则一组个数:num_output/ group (必须整除)
		    weight_filler {
		      type: "msra"    
		    }
		    engine: CAFFE
		  }
}

猜你喜欢

转载自blog.csdn.net/u011681952/article/details/86157060
今日推荐