!48068 add necessary imports for Demo code

Merge pull request !48068 from 李林杰/code_docs_0119_fix_docs_alpha20
This commit is contained in:
i-robot 2023-01-19 08:44:22 +00:00 committed by Gitee
commit f9dcdba238
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 10 additions and 3 deletions

View File

@ -800,8 +800,12 @@ def resize_nearest_neighbor(input_x, size, align_corners=False):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import numpy as np
>>> import mindspore
>>> from mindspore import Tensor, ops
>>> input_tensor = Tensor(np.array([[[[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]]]]), mindspore.float32)
>>> output = ops.ResizeNearestNeighbor(input_tensor, (2, 2))
>>> size = (2, 2)
>>> output = ops.ResizeNearestNeighbor(size=size)(input_tensor)
>>> print(output)
[[[[-0.1 0.3]
[ 0.4 0.5]]]]

View File

@ -3702,9 +3702,12 @@ class ResizeNearestNeighbor(Primitive):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import numpy as np
>>> import mindspore
>>> from mindspore import Tensor, ops
>>> input_tensor = Tensor(np.array([[[[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]]]]), mindspore.float32)
>>> resize = ops.ResizeNearestNeighbor((2, 2))
>>> output = resize(input_tensor)
>>> size = (2, 2)
>>> output = ops.ResizeNearestNeighbor(size=size)(input_tensor)
>>> print(output)
[[[[-0.1 0.3]
[ 0.4 0.5]]]]