mindspore.ops.ResizeBilinearV2
- class mindspore.ops.ResizeBilinearV2(align_corners=False, half_pixel_centers=False)[source]
Resizes an image to a certain size using the bilinear interpolation.
The resizing only affects the lower two dimensions which represent the height and width.
Warning
This is an experimental API that is subject to change or deletion.
- Parameters
align_corners (bool, optional) – If
True
, rescale input by \((new\_height - 1) / (height - 1)\), which exactly aligns the 4 corners of images and resized images. IfFalse
, rescale by \(new\_height / height\). Default:False
.half_pixel_centers (bool, optional) – Whether half pixel center. If set to
True
, align_corners should beFalse
. Default:False
.
- Inputs:
x (Tensor) - Image to be resized. Input images must be a 4-D tensor with shape \((batch, channels, height, width)\), with data type of float32 or float16.
size (Union[tuple[int], list[int], Tensor]) - The new size of the images. A tuple or list or Tensor of 2 int elements \((new\_height, new\_width)\).
- Outputs:
Tensor, resized image. 4-D with shape \((batch, channels, new\_height, new\_width)\), with the same data type as input x.
- Raises
TypeError – If align_corners is not a bool.
TypeError – If half_pixel_centers is not a bool.
TypeError – If align_corners and half_pixel_centers are all
True
.ValueError – If half_pixel_centers is
True
and device_target is CPU.ValueError – If dim of x is not 4.
ValueError – If size is Tensor and its dim is not 1.
ValueError – If size contains other than 2 elements.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> from mindspore import Tensor, ops >>> x = Tensor([[[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]]], mindspore.float32) >>> output = ops.ResizeBilinearV2()(x, (5, 5)) >>> print(output) [[[[1. 2. 3. 4. 5.] [1. 2. 3. 4. 5.] [1. 2. 3. 4. 5.] [1. 2. 3. 4. 5.] [1. 2. 3. 4. 5.]]]]