caffe之(二)pooling层

时间:2023-03-08 17:30:20

在caffe中,网络的结构由prototxt文件中给出,由一些列的Layer(层)组成,常用的层如:数据加载层、卷积操作层、pooling层、非线性变换层、内积运算层、归一化层、损失计算层等;本篇主要介绍pooling层

1. Pooling层总述

下面首先给出pooling层的结构设置的一个小例子(定义在.prototxt文件中)

layer {
name: "pool1" //该层的名称
type: "Pooling" //该层的类型
bottom: "norm1" //该层的输入数据blob
top: "pool1" //该层的输出数据blob // 该层的相关参数设置
pooling_param {
pool: MAX //pooling类型,默认值为MAX,也可以设置为AVE,STOCHASTIC
kernel_size: //pooling核大小,为必设参数
stride: //pooling核步长,默认值为1(即重叠),但通常设置为2;
} }

注:在caffe的原始proto文件中,关于卷积层的参数PoolingParameter定义如下:

message PoolingParameter {
enum PoolMethod {
MAX = ;
AVE = ;
STOCHASTIC = ;
}
optional PoolMethod pool = [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 = [default = ]; // The padding size (equal in Y, X)
optional uint32 pad_h = [default = ]; // The padding height
optional uint32 pad_w = [default = ]; // The padding width
optional uint32 kernel_size = ; // The kernel size (square)
optional uint32 kernel_h = ; // The kernel height
optional uint32 kernel_w = ; // The kernel width
optional uint32 stride = [default = ]; // The stride (equal in Y, X)
optional uint32 stride_h = ; // The stride height
optional uint32 stride_w = ; // The stride width
enum Engine {
DEFAULT = ;
CAFFE = ;
CUDNN = ;
}
optional Engine engine = [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
optional bool global_pooling = [default = false];
}