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.
\[\begin{split}\begin{array}{ll} \\ n' = n*(block\_size[0] * ... * block\_size[M]) \\ w'_i = (w_i + paddings[i][0] + paddings[i][1])//block\_size[i] \end{array}\end{split}\]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 \((n, c_1, ... c_k, w_1, ..., w_M)\), then the output shape will be \((n', c_1, ... c_k, w'_1, ..., w'_M)\).
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.]]]]