mindspore.ops.DepthToSpace
- class mindspore.ops.DepthToSpace(block_size)[source]
Rearrange blocks of depth data into spatial dimensions.
This is the reverse operation of SpaceToDepth.
The depth of output tensor is
.The output tensor's height dimension is
.The output tensor's weight dimension is
.The input tensor's depth must be divisible by block_size * block_size. The data format is "NCHW".
- Parameters
block_size (int) – The block size used to divide depth data. It must be >= 2.
- Inputs:
x (Tensor) - The target tensor. It must be a 4-D tensor with shape
. The data type is Number.
- Outputs:
Tensor of shape
.
- Raises
TypeError – If block_size is not an int.
ValueError – If block_size is less than 2.
ValueError – If length of shape of x is not equal to 4.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, ops >>> x = Tensor(np.random.rand(1, 12, 1, 1), mindspore.float32) >>> block_size = 2 >>> depth_to_space = ops.DepthToSpace(block_size) >>> output = depth_to_space(x) >>> print(output.shape) (1, 3, 2, 2)