pytorch / 2 / generated / torch.nn.adaptiveavgpool1d.html

AdaptiveAvgPool1d

class torch.nn.AdaptiveAvgPool1d(output_size) [source]

Applies a 1D adaptive average pooling over an input signal composed of several input planes.

The output size is L o u t L_{out} , for any input size. The number of output features is equal to the number of input planes.

Parameters

output_size (Union[int, Tuple[int]]) – the target output size L o u t L_{out} .

Shape:
  • Input: ( N , C , L i n ) (N, C, L_{in}) or ( C , L i n ) (C, L_{in}) .
  • Output: ( N , C , L o u t ) (N, C, L_{out}) or ( C , L o u t ) (C, L_{out}) , where L o u t = output_size L_{out}=\text{output\_size} .

Examples

>>> # target output size of 5
>>> m = nn.AdaptiveAvgPool1d(5)
>>> input = torch.randn(1, 64, 8)
>>> output = m(input)

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.nn.AdaptiveAvgPool1d.html