mindspore.ops.ResizeNearestNeighbor
- class mindspore.ops.ResizeNearestNeighbor(size, align_corners=False)[source]
Resizes the input tensor by using the nearest neighbor algorithm.
Resizes the input tensor to a given size by using the nearest neighbor algorithm. The nearest neighbor algorithm selects the value of the nearest point and does not consider the values of neighboring points at all, yielding a piecewise-constant interpolant.
- Parameters
- Inputs:
input_x (Tensor) - The input tensor. The shape of the tensor is \((N, C, H, W)\).
- Outputs:
- Tensor, the shape of the output tensor is \((N, C, NEW\_H, NEW\_W)\).
The data type is same as the input_x.
- Raises
TypeError – If size is neither tuple nor list.
TypeError – If align_corners is not a bool.
ValueError – If length of size is not equal to 2.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> 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) >>> print(output) [[[[-0.1 0.3] [ 0.4 0.5]]]]