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.UpsampleNearest3D

View Source On Gitee
class mindspore.ops.UpsampleNearest3D[source]

Performs nearest neighbor upsampling operation.

This operator scale up the volumetric input with specified output_size or scales factors, using nearest neighbor algorithm.

One of output_size or scales must be given, and can not specified both at the same time.

Inputs:
  • x (Tensor) - 5D tensor of shape (N,C,Din,Hin,Win). Supporting types: [float16, float32, float64].

  • output_size (Union[tuple[int], list[int]]): A tuple or list of int specifying the output volumetric size. Default: None.

  • scales (Union[tuple[float], list[float]]): A tuple or list of float specifying the upsampling factors. Default: None.

Outputs:
  • y (Tensor) - Upsampled output with the same type as x , whose shape is (N,C,Dout,Hout,Wout).

Raises
  • TypeError – When output_size is not None and output_size is not list[int] or tuple[int].

  • TypeError – When scales is not None and scales is not list[float] or tuple[float].

  • TypeError – If dtype of x is not int [uint8, float16, float32, float64].

  • ValueError – If any value of output_size is negative or zero when output_size is not None.

  • ValueError – If any value of scales is negative or zero when scales is not None.

  • ValueError – If shape of x is not 5D.

  • ValueError – If none of scales and output_size is specified or both specified.

  • ValueError – If size of scales is not equal 3 when scales is specified.

  • ValueError – If size of output_size is not equal 3 when output_size is specified.

Supported Platforms:

Ascend 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)
>>> output_size = [3, 4, 5]
>>> net = ops.UpsampleNearest3D()
>>> output = net(x, output_size, None)
>>> print(output)
[[[[[ 1.  1.  2.  3.  4.]
    [ 1.  1.  2.  3.  4.]
    [ 5.  5.  6.  7.  8.]
    [ 5.  5.  6.  7.  8.]]
   [[ 1.  1.  2.  3.  4.]
    [ 1.  1.  2.  3.  4.]
    [ 5.  5.  6.  7.  8.]
    [ 5.  5.  6.  7.  8.]]
   [[ 9.  9. 10. 11. 12.]
    [ 9.  9. 10. 11. 12.]
    [13. 13. 14. 15. 16.]
    [13. 13. 14. 15. 16.]]]]]