mindspore.ops.max_pool3d
- mindspore.ops.max_pool3d(x, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False)[source]
Performs a 3D max pooling on the input Tensor.
Typically the input is a Tensor with shape \((N_{in}, C_{in}, D_{in}, H_{in}, W_{in})\), outputs regional maximum in the \((D_{in}, H_{in}, W_{in})\)-dimension. Given kernel_size \(ks = (d_{ker}, h_{ker}, w_{ker})\) and stride \(s = (s_0, s_1, s_2)\), the operation is as follows.
\[\text{output}(N_i, C_j, d, h, w) = \max_{l=0, \ldots, d_{ker}-1} \max_{m=0, \ldots, h_{ker}-1} \max_{n=0, \ldots, w_{ker}-1} \text{input}(N_i, C_j, s_0 \times d + l, s_1 \times h + m, s_2 \times w + n)\]- Parameters
x (Tensor) – Tensor of shape \((N_{in}, C_{in}, D_{in}, H_{in}, W_{in})\) with data type of int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32 or float64.
kernel_size (Union[int, tuple[int]]) – The size of kernel used to take the maximum value and arg value, is an int number that represents depth, height and width of the kernel, or a tuple of three int numbers that represent depth, height and width respectively.
stride (Union[int, tuple[int]]) – The distance of kernel moving, an int number that represents the depth, height and width of movement are both stride, or a tuple of three int numbers that represent depth, height and width of movement respectively. Default: kernel_size.
padding (Union[int, tuple[int]]) – An int number that represents the depth, height and width of movement are both strides, or a tuple of three int numbers that represent depth, height and width of movement respectively. Default: 0.
dilation (Union[int, tuple[int]]) – Control the stride of elements in the kernel. Default: 1.
ceil_mode (bool) – Whether to use ceil instead of floor to calculate output shape. Default: False.
return_indices (bool) – Whether to output the indices of max value. Default: False.
- Returns
If return_indices is False, return a Tensor output, else return a tuple (output, argmax).
output (Tensor) - Maxpooling result, with shape \((N_{out}, C_{out}, D_{out}, H_{out}, W_{out})\). It has the same data type as x.
argmax (Tensor) - Index corresponding to the maximum value. Data type is int64. It will be return only when return_indices is True.
- Raises
TypeError – If x is not a Tensor.
ValueError – If length of shape of x is not equal to 5.
TypeError – If kernel_size , stride , padding or dilation is not int or tuple.
ValueError – If kernel_size or stride is less than 1.
ValueError – If padding is less than 0.
- Supported Platforms:
GPU
Examples
>>> x = Tensor(np.arange(2 * 1 * 2 * 2 * 2).reshape((2, 1, 2, 2, 2)), mindspore.float32) >>> output_tensor, argmax = ops.max_pool3d(x, kernel_size=2, stride=1, padding=1, return_indices=True) >>> print(output_tensor.shape) (2, 1, 3, 3, 3) >>> print(argmax.shape) (2, 1, 3, 3, 3)