# mxnet.ndarray.depth_to_space¶

mxnet.ndarray.depth_to_space(data=None, block_size=_Null, out=None, name=None, **kwargs)

Rearranges(permutes) data from depth into blocks of spatial data. Similar to ONNX DepthToSpace operator: https://github.com/onnx/onnx/blob/master/docs/Operators.md#DepthToSpace. The output is a new tensor where the values from depth dimension are moved in spatial blocks to height and width dimension. The reverse of this operation is space_to_depth.

$\begin{split}\begin{gather*} x \prime = reshape(x, [N, block\_size, block\_size, C / (block\_size ^ 2), H * block\_size, W * block\_size]) \\ x \prime \prime = transpose(x \prime, [0, 3, 4, 1, 5, 2]) \\ y = reshape(x \prime \prime, [N, C / (block\_size ^ 2), H * block\_size, W * block\_size]) \end{gather*}\end{split}$

where $$x$$ is an input tensor with default layout as $$[N, C, H, W]$$: [batch, channels, height, width] and $$y$$ is the output tensor of layout $$[N, C / (block\_size ^ 2), H * block\_size, W * block\_size]$$

Example:

x = [[[[0, 1, 2],
[3, 4, 5]],
[[6, 7, 8],
[9, 10, 11]],
[[12, 13, 14],
[15, 16, 17]],
[[18, 19, 20],
[21, 22, 23]]]]

depth_to_space(x, 2) = [[[[0, 6, 1, 7, 2, 8],
[12, 18, 13, 19, 14, 20],
[3, 9, 4, 10, 5, 11],
[15, 21, 16, 22, 17, 23]]]]


Defined in src/operator/tensor/matrix_op.cc:L1002

Parameters
• data (NDArray) – Input ndarray

• block_size (int, required) – Blocks of [block_size. block_size] are moved

• out (NDArray, optional) – The output NDArray to hold the result.

Returns

out – The output of this function.

Return type

NDArray or list of NDArrays