mindspore.ops.UpsampleTrilinear3D
- class mindspore.ops.UpsampleTrilinear3D(output_size=None, scales=None, align_corners=False)[source]
Performs upsampling with trilinear interpolation across 3dims for 5dim input Tensor.
This operator scale up the volumetric input with specified output_size or scales factors, using trilinear upscaling algorithm.
Note
One of scales and output_size MUST be specified and it is an error if both are specified.
- Parameters
output_size (Union[tuple[int], list[int]], optional) – A tuple or list of 3 int elements \((output\_depth, output\_height, output\_width)\). Defaults to None. Only one of scales and output_size can be specified.
scales (Union[tuple[float], list[float]], optional) – A tuple or list of 3 float elements \((scale\_depth, scale\_height, scale\_width)\). Defaults to None.
align_corners (bool, optional) – An optional bool. Defaults to false. If True, the input and output tensors are aligned by the center points of their corner pixels, preserving the values at the corner pixels. If False, the input and output tensors are aligned by the corner points of their corner pixels, and the interpolation use edge value padding for out of boundary values.
- Inputs:
x (Tensor) - A 5-D input tensor of shape \((N, C, D_{in}, H_{in}, W_{in})\). Must be one of the following types: float16, float32, float64.
- Outputs:
y (Tensor) - Upsampled output with the same data type as x. Tensor of shape \((N, C, D_{out}, H_{out}, W_{out})\).
- 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 in [float16, float32, float64].
TypeError – If type of align_corners is not bool.
ValueError – If any value of output_size is negative or zero when output_size is not empty.
ValueError – If any value of scales is negative or zero when scales is not empty.
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:
GPU
CPU
Examples
>>> ops = ops.UpsampleTrilinear3D(output_size=[4, 64, 48]) >>> out = ops(Tensor(input_data=np.random.randn(2, 3, 4, 512, 256))) >>> print(out.shape) (2, 3, 4, 64, 48) ... >>> ops = ops.UpsampleTrilinear3D(output_size=[2, 4, 4]) >>> in_x = Tensor(np.arange(1, 5, dtype=np.float32).reshape((1, 1, 1, 2, 2))) >>> out = ops(in_x) >>> print(out) [[[[[1. 1.25 1.75 2. ] [1.5 1.75 2.25 2.5 ] [2.5 2.75 3.25 3.5 ] [3. 3.25 3.75 4. ]] [[1. 1.25 1.75 2. ] [1.5 1.75 2.25 2.5 ] [2.5 2.75 3.25 3.5 ] [3. 3.25 3.75 4. ]]]]]