Applies a 1D adaptive max pooling over an input signal composed of several input planes.
The output size is Lout, for any input size.
The number of output features is equal to the number of input planes.
Each output element is the maximum over a region of the input whose bounds are
derived from the input and output sizes:
start(k)=⌊Loutk×Lin⌋end(k)=⌈Lout(k+1)×Lin⌉
out(Ni,Cj,k)=start(k)≤l<end(k)maxinput(Ni,Cj,l) When Lin is not divisible by Lout, these regions may have
different sizes and may overlap. For example, an input of size 5 pooled to size 3
uses the regions [0,2), [1,4) and [3,5).
- Parameters:
output_size (int | tuple[int]) – the target output size Lout.
return_indices (bool) – if True, will return the indices along with the outputs.
Useful to pass to nn.MaxUnpool1d. Default: False
- Shape:
Input: (N,C,Lin) or (C,Lin).
Output: (N,C,Lout) or (C,Lout), where
Lout=output_size.
Examples
>>> # target output size of 5
>>> m = nn.AdaptiveMaxPool1d(5)
>>> input = torch.randn(1, 64, 8)
>>> output = m(input)
-
forward(input)[source]
Runs the forward pass.