评价此页

torch.nn.functional.avg_pool1d#

torch.nn.functional.avg_pool1d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True) Tensor#

对由多个输入平面组成的输入信号进行1D平均池化操作。

详细信息及输出形状请参阅 AvgPool1d

参数:
  • input – 输入张量,形状为 (minibatch,in_channels,iW)(\text{minibatch} , \text{in\_channels} , iW)

  • kernel_size – 窗口大小。可以是一个数字或元组 (kW,)

  • stride – 窗口的步长。可以是一个数字或元组 (sW,)。默认值:kernel_size

  • padding – 输入两侧的隐式零填充。可以是一个数字或元组 (padW,)。最大值应为有效核大小的一半,即 ((kernelSize1)dilation+1)/2((kernelSize - 1) * dilation + 1) / 2。默认值:0

  • ceil_mode – 如果为 True,将使用 ceil(向上取整)而不是 floor(向下取整)来计算输出形状。默认值:False

  • count_include_pad – when True, will include the zero-padding in the averaging calculation. Default: True

示例

>>> # pool of square window of size=3, stride=2
>>> input = torch.tensor([[[1, 2, 3, 4, 5, 6, 7]]], dtype=torch.float32)
>>> F.avg_pool1d(input, kernel_size=3, stride=2)
tensor([[[ 2.,  4.,  6.]]])