mindspore.ops.space_to_batch_nd
- mindspore.ops.space_to_batch_nd(input_x, block_size, paddings)[source]
Divides a tensor's spatial dimensions into blocks and combines the block sizes with the original batch.
Note
This operation divides the spatial dimensions [1, …, M] of the input into blocks of size block_size and interleaves them into the batch dimension (default: dimension 0). Before splitting, the spatial dimensions are padded with zeros according to paddings.
If the input shape is
, then the output shape will be .If block_size is a tuple or list, the length of block_size is M corresponding to the number of spatial dimensions. If block_size is an int, the block size of M dimensions are the same, equal to block_size. M must be 2 on Ascend.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> block_size = [2, 2] >>> paddings = [[0, 0], [0, 0]] >>> input_x = mindspore.tensor([[[[1, 2], [3, 4]]]], mindspore.float32) >>> output = mindspore.ops.space_to_batch_nd(input_x, block_size, paddings) >>> print(output) [[[[1.]]] [[[2.]]] [[[3.]]] [[[4.]]]]