caffe卷积层参数

axis

1
2
3
4
5
6
7
8
9
10
// 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];

说白了,就是将哪个轴作为通道,默认为1,默认为1的话就是第二个轴为通道[0,1,2,3]。

1
2
// Preceding dimensions are treated as independent inputs;`
// succeeding dimensions are treated as "spatial".

前边的轴作为独立输入,后边的轴作为空间坐标轴。

另外一个函数:

1
2
3
4
5
6
7
8
9
10
11
12
inline int CanonicalAxisIndex(int axis_index) const {
CHECK_GE(axis_index, -num_axes())
<< "axis " << axis_index << " out of range for " << num_axes()
<< "-D Blob with shape " << shape_string();
CHECK_LT(axis_index, num_axes())
<< "axis " << axis_index << " out of range for " << num_axes()
<< "-D Blob with shape " << shape_string();
if (axis_index < 0) {
return axis_index + num_axes();
}
return axis_index;
}

返回Canonical的index,字面意思是权威。实际如下:

1
2
3
input: 0,1,2,3
-4,-3,-2,-1
output: 0,1,2,3