1、池化层——Pooling Layer
nn.MaxPool2d
nn.MaxPool2d(kernel_size, stride=None,
padding=0, dilation=1,
return_indices=False,
ceil_mode=False)
kernel_size:池化核尺寸;
stride:步长;
padding:填充个数;
dilation:池化核间隔大小;
ceil_mode:池化过程中有一个除法操作,当不能整除时,如果参数设置为True,尺寸向上取整,默认参数值是False,向下取整;
return_indices:记录池化像素索引,记录最大值像素所在的位置索引,通常在最大值反池化中使用;
nn.AvgPool2d
nn.AvgPool2d(kernel_size,
stride=None,
padding=0,
ceil_mode=False,
count_include_pad=True,
divisor_override=None)
kernel_size:池化核尺寸;
stride:步长;
padding:填充个数;
ceil_mode:尺寸向上取整;
count_include_pad:如果参数值为True,使用填充值用于计算;
divisor_override:求平均值的时候,可以不使用像素值的个数作为分母,而是使用除法因子;
nn.MaxUnpool2d
**功能:**对二维信号(图像)进行最大值池化上采样,将小尺寸图片池化为大尺寸图片;
nn.MaxUnpool2d(kernel_size,
stride=None,
padding=0)
forward(self, input, indices, output_size=None)
kernel_size:池化核尺寸
stride:步长
padding:填充个数
2、线性层——Linear Layer
nn.Linear
功能: 对一维信号(向量)进行线性组合;
nn.Linear(in_features, out_features, bias=True)
主要参数:
in_features:输入结点数;
out_features:输出结点数;
bias:是否需要偏置
计算公式: y = x W T + b i a s y=xW^T+bias y=xWT+bias