评价此页

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.]]])