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 – 輸入張量,形狀為
kernel_size – 視窗大小。可以是單個數字或元組 (kW,)
stride – 視窗的步長。可以是單個數字或元組 (sW,)。預設為
kernel_sizepadding – 輸入兩端的隱式零填充。可以是單個數字或元組 (padW,)。應最多為有效核大小的一半,即 。預設為 0
ceil_mode – 如果為 True,將使用 ceil 而不是 floor 來計算輸出形狀。預設為
Falsecount_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.]]])