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

  • Post author:
  • Post category:其他

MaxPool1d

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

输入size为(N,C,L),在L维进行池化
在这里插入图片描述
参数:

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:
在这里插入图片描述
示例:

>>> # 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)

在这里插入图片描述
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
在这里插入图片描述
示例:

>>> # 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)

在这里插入图片描述
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:
在这里插入图片描述
示例:

>>> # 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)

版权声明:本文为yrwang_xd原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。