class oneflow.nn.AdaptiveMaxPool2d(output_size, return_indices=False, data_format=None)

Applies a 2D adaptive max pooling over an input signal composed of several input planes.

The documentation is referenced from:

The output is of size \(H_{out} \times W_{out}\), for any input size. The number of output features is equal to the number of input planes.

  • output_size – the target output size of the image of the form \(H_{out} \times W_{out}\). Can be a tuple \((H_{out}, W_{out})\) or a single \(H_{out}\) for a square image \(H_{out} \times H_{out}\). \(H_{out}\) and \(W_{out}\) should be a int.

  • return_indices – if True, will return the indices along with the outputs. Default: False

  • Input: \((N, C, H_{in}, W_{in})\).

  • Output: \((N, C, H_{out}, W_{out})\), where \((H_{out}, W_{out})=\text{output_size}\).


>>> import oneflow as flow
>>> import oneflow.nn as nn
>>> # target output size of 5x7
>>> m = nn.AdaptiveMaxPool2d((5,7))
>>> input = flow.randn(1, 64, 8, 9)
>>> output = m(input)
>>> print(output.shape)
oneflow.Size([1, 64, 5, 7])
>>> # target output size of 7x7 (square)
>>> m = nn.AdaptiveMaxPool2d(7)
>>> input = flow.randn(1, 64, 10, 9)
>>> output = m(input)
>>> print(output.shape)
oneflow.Size([1, 64, 7, 7])