class
AdaptiveMaxPool1d
extends
ModuleAdaptiveMaxPool1d(output_size: int | tuple[int, ...], return_indices: bool = False)Applies adaptive 1-D max pooling to produce a fixed output length.
For each output position , the window boundaries are:
and the output is:
Parameters
output_sizeint or tuple[int, ...]Desired output length.
return_indicesbool= FalseNot yet supported. Default:
False.Attributes
output_sizeint or tuple[int, ...]Notes
- Input:
(N, C, L_in) - Output:
(N, C, output_size)
- Adaptive max pooling retains the strongest activation in each adaptively-sized segment, combining the spatial invariance of max pooling with input-size flexibility.
- This layer is frequently used in region-proposal networks and variable-length sequence encoders.
Examples
Compress sequence to fixed length 4:
>>> import lucid
>>> import lucid.nn as nn
>>> pool = nn.AdaptiveMaxPool1d(output_size=4)
>>> x = lucid.ones((2, 32, 50))
>>> y = pool(x)
>>> y.shape
(2, 32, 4)
Global max pooling (output_size=1):
>>> gmp = nn.AdaptiveMaxPool1d(output_size=1)
>>> x = lucid.ones((4, 128, 200))
>>> y = gmp(x)
>>> y.shape
(4, 128, 1)Used by 1
Constructors
1Instance methods
2Return a string representation of the layer's configuration.