Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.fractional_max_pool3d

View Source On Gitee
mindspore.ops.fractional_max_pool3d(input, kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None)[source]

Applies the 3D FractionalMaxPool operation over input. The output Tensor shape can be determined by either output_size or output_ratio, and the step size is determined by _random_samples. output_size will take effect when output_size and output_ratio are set at the same time. And output_size and output_ratio can not be None at the same time.

Refer to the paper Fractional MaxPooling by Ben Graham for more details.

The input and output data format can be "NCDHW". N is the batch size, C is the number of channels, D the feature depth, H is the feature height, and W is the feature width.

Warning

This is an experimental API that is subject to change or deletion.

Parameters
  • input (Tensor) – The input of FractionalMaxPool3d, which is a 4D or 5D tensor. Tensor of data type: float16, float32, double. Supported shape (N,C,Din,Hin,Win) or (C,Din,Hin,Win).

  • kernel_size (Union[int, tuple[int]]) – The size of kernel used to take the maximum 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. The value must be a positive integer.

  • output_size (Union[int, tuple[int]], optional) – The shape of the target output_size, is an int number that represents depth, height and width, or a tuple of three int numbers that represent depth, height and width respectively. The value must be a positive integer. Default: None .

  • output_ratio (Union[float, tuple[float]], optional) – The ratio of target output shape to input shape. Specifying the size of the output tensor by using a ratio of the input size. Data type: float16, float32, double, and value is between (0, 1). Default: None .

  • return_indices (bool, optional) – Whether to return the indices of max value. Default: False .

  • _random_samples (Tensor, optional) – The random step of fractional_max_pool3d, which is a 3D tensor. Tensor of data type: float16, float32, double, and value is between [0, 1). Supported shape (N,C,3) or (1,C,3) . Default: None, the values of _random_samples will be randomly distributed using uniform distribution over an interval [0,1).

Returns

  • y (Tensor) - A tensor, the output of FractionalMaxPool3d. Has the same data type with input. Has the shape (N,C,Dout,Hout,Wout) or (C,Dout,Hout,Wout) , where (Dout,Hout,Wout) = output_size or (Dout,Hout,Wout) = output_ratio * (Din,Hin,Win) .

  • argmax (Tensor) - The indices along with the outputs, which is a Tensor, with the same shape as the y and int32 data type. It will output only when return_indices is True.

Raises
  • TypeError – If input is not a 4D or 5D tensor.

  • TypeError – If _random_samples is not a 3D tensor.

  • TypeError – If data type of input is not float16, float32, double, int32, int64.

  • TypeError – If dtype of _random_samples is not float16, float32, double.

  • TypeError – If dtype of argmax is not int32, int64.

  • TypeError – if _random_samples to have the different dtypes as input.

  • ValueError – If output_size is a tuple and if output_size length is not 3.

  • ValueError – If kernel_size is a tuple and if kernel_size length is not 3.

  • ValueError – If numbers in output_size or kernel_size is not positive.

  • ValueError – if output_size and output_ratio are None at the same time.

  • ValueError – If the first dimension size of input and _random_samples is not equal.

  • ValueError – If the second dimension size of input and _random_samples is not equal.

  • ValueError – If the third dimension size of _random_samples is not 3.

Supported Platforms:

GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> from mindspore import dtype as mstype
>>> x = Tensor(np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
...            .reshape([1, 1, 2, 2, 4]), mstype.float32)
>>> _random_samples = Tensor(np.array([0.7, 0.7, 0.7]).reshape([1, 1, 3]), mstype.float32)
>>> output, argmax = ops.fractional_max_pool3d(x, kernel_size=(1, 1, 1), output_size=(1, 1, 3),
...                                            _random_samples=_random_samples, return_indices=True)
>>> print(output)
[[[[[13. 14. 16.]]]]]
>>> print(argmax)
[[[[[12 13 15]]]]]
>>> output, argmax = ops.fractional_max_pool3d(x, kernel_size=(1, 1, 1), output_ratio=(0.5, 0.5, 0.5),
...                                            _random_samples=_random_samples, return_indices=True)
>>> print(output)
[[[[[13. 16.]]]]]
>>> print(argmax)
[[[[[12 15]]]]]