保障外出租地农民的权益就是保障失地农民...

paddle.nn.functional. adaptive_max_pool1d ( x: Tensor, output_size: int, return_mask: bool = False, name: str | None = None ) Tensor [source]
百度 这项百姓参演,专家、名家指导的文化惠民活动,已经坚持了四年,极大地丰富了人民群众的精神文化生活。

This API implements adaptive max pooling 1d operation. See more details in AdaptiveMaxPool1D .

Parameters
  • x (Tensor) – The input tensor of pooling operator, which is a 3-D tensor with shape [N, C, L]. The format of input tensor is NCL, where N is batch size, C is the number of channels, L is the length of the feature. The data type is float32 or float64.

  • output_size (int) – The pool kernel size. The value should be an integer.

  • return_mask (bool) – If true, the index of max pooling point will be returned along with outputs. It cannot be set in average pooling type. Default False.

  • name (str|None, optional) – For detailed information, please refer to Name. Usually name is no need to set and None by default.

Returns

The output tensor of adaptive pooling result. The data type is same

as input tensor.

Return type

Tensor

Examples

>>> # max adaptive pool1d
>>> # suppose input data in shape of [N, C, L], `output_size` is m or [m],
>>> # output shape is [N, C, m], adaptive pool divide L dimension
>>> # of input data into m grids averagely and performs poolings in each
>>> # grid to get output.
>>> # adaptive max pool performs calculations as follow:
>>> #
>>> #     for i in range(m):
>>> #         lstart = floor(i * L / m)
>>> #         lend = ceil((i + 1) * L / m)
>>> #         output[:, :, i] = max(input[:, :, lstart: lend])
>>> #
>>> import paddle
>>> import paddle.nn.functional as F

>>> data = paddle.uniform([1, 3, 32], paddle.float32)
>>> pool_out = F.adaptive_max_pool1d(data, output_size=16)
>>> print(pool_out.shape)
[1, 3, 16]
>>> pool_out, indices = F.adaptive_max_pool1d(data, output_size=16, return_mask=True)
>>> print(pool_out.shape)
[1, 3, 16]
>>> print(indices.shape)
[1, 3, 16]