mindspore.nn.AdaptiveMaxPool3d

class mindspore.nn.AdaptiveMaxPool3d(output_size, return_indices=False)[source]

Calculates the 3D adaptive max pooling for an input Tensor. That is, for any input size, the size of the specified output is \((D, H, W)\).

Parameters
  • output_size (Union[int, tuple]) – The specified output size, which is a positive integer that represents depth, height and width, or a tuple of three positive integers that represent depth, height and width respectively. If it is None, the output size and input size of the corresponding dimension are the same.

  • return_indices (bool, optional) – If return_indices is True , the indices of max value would be output. Otherwise, the indices will not be returned. Default: False .

Inputs:
  • input (Tensor) - Tensor, has shape of \((C, D, H, W)\) or \((N, C, D, H, W)\).

Outputs:
  • y (Tensor) - Tensor, has the same number of dims and data type as the input .

  • argmax (Tensor) - Tensor, the indices of the maximum values along with the outputs, has the same shape as y and a dtype of int32. Return this only when return_indices is True .

Raises
  • TypeError – If input is not a Tensor.

  • ValueError – If the dimensions number of input is not 4 or 5.

  • TypeError – If dtype of input is not int, uint or float.

  • ValueError – If output_size is neither an int nor a tuple with shape \((3,)\).

Supported Platforms:

GPU CPU

Examples

>>> import mindspore as ms
>>> import numpy as np
>>> input = ms.Tensor(np.arange(0,36).reshape((1, 3, 3, 4)).astype(np.float32))
>>> output_size = (1, 1, 2)
>>> net = ms.nn.AdaptiveMaxPool3d(output_size, True)
>>> output = net(input)
>>> print(output[0].asnumpy())
[[[[33. 35.]]]]
>>> print(output[1].asnumpy())
[[[[33 35]]]]