pytorch系列文档之Pooling layers详解(MaxPool1d、MaxPool2d、MaxPool3d)

MaxPool1d

torch.nn.MaxPool1d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

输入size为(N,C,L),在L维进行池化
pytorch系列文档之Pooling layers详解(MaxPool1d、MaxPool2d、MaxPool3d)_第1张图片
参数:

kernel_size – 池化窗口大小
stride – 步长. Default value is kernel_size
padding – padding的值,默认就是不padding
dilation – 控制扩张的参数
return_indices – if True, will return the max indices along with the outputs. Useful for torch.nn.MaxUnpool1d later
ceil_mode – when True, 会用向上取整而不是向下取整来计算output的shape

shape:
pytorch系列文档之Pooling layers详解(MaxPool1d、MaxPool2d、MaxPool3d)_第2张图片
示例:

>>> # pool of size=3, stride=2
>>> m = nn.MaxPool1d(3, stride=2)
>>> input = torch.randn(20, 16, 50)
>>> output = m(input)

MaxPool2d

torch.nn.MaxPool2d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

pytorch系列文档之Pooling layers详解(MaxPool1d、MaxPool2d、MaxPool3d)_第3张图片
kernel_size, stride, padding, dilation 这四个值可以是以下两种中的一个:

a single intin which case the same value is used for the height and width dimension
a tuple of two ints – in which case, the first int is used for the height dimension, and the second int for the width dimension

参数:与1d一致
shape
pytorch系列文档之Pooling layers详解(MaxPool1d、MaxPool2d、MaxPool3d)_第4张图片
示例:

>>> # pool of square window of size=3, stride=2
>>> m = nn.MaxPool2d(3, stride=2)
>>> # pool of non-square window
>>> m = nn.MaxPool2d((3, 2), stride=(2, 1))
>>> input = torch.randn(20, 16, 50, 32)
>>> output = m(input)

MaxPool3d

torch.nn.MaxPool3d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

pytorch系列文档之Pooling layers详解(MaxPool1d、MaxPool2d、MaxPool3d)_第5张图片
kernel_size, stride, padding, dilation 这四个值可以是以下两种中的一个:

a single intin which case the same value is used for the depth, height and width dimension
a tuple of three ints – in which case, the first int is used for the depth dimension, the second int for the height dimension and the third int for the width dimension

参数:与1d一致
Shape:
pytorch系列文档之Pooling layers详解(MaxPool1d、MaxPool2d、MaxPool3d)_第6张图片
示例:

>>> # pool of square window of size=3, stride=2
>>> m = nn.MaxPool3d(3, stride=2)
>>> # pool of non-square window
>>> m = nn.MaxPool3d((3, 2, 2), stride=(2, 1, 2))
>>> input = torch.randn(20, 16, 50,44, 31)
>>> output = m(input)

你可能感兴趣的:(pytorch)