mindspore.ops.DepthToSpace
- class mindspore.ops.DepthToSpace(block_size)[源代码]
Rearrange blocks of depth data into spatial dimensions.
This is the reverse operation of SpaceToDepth.
The depth of output tensor is \(input\_depth / (block\_size * block\_size)\).
The output tensor’s height dimension is \(height * block\_size\).
The output tensor’s weight dimension is \(weight * block\_size\).
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 \((N, C_{in}, H_{in}, W_{in})\). The data type is Number.
- Outputs:
Tensor of shape \((N, C_{in} / \text{block_size} ^ 2, H_{in} * \text{block_size}, W_{in} * \text{block_size})\).
- 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
>>> 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)