depth_to_space

dragon.nn.depth_to_space(
  inputs,
  block_size,
  data_format='NCHW',
  **kwargs
)[source]

Rearrange depth data into spatial blocks.

Examples:

n, c, h, w, bs = 1, 4, 1, 1, 2
x = dragon.arange(n * c * h * w).reshape((n, c, h, w))
y = dragon.reshape(x, (n, bs, bs, c // (bs ** 2), h, w))
y = dragon.transpose(y, (0, 3, 4, 1, 5, 2))
y = dragon.reshape(y, (n, c // (bs ** 2), h * bs, w * bs))
z = dragon.nn.depth_to_space(x, 2)  # Equivalent
Parameters:
  • inputs (dragon.Tensor) – The input tensor.
  • block_size (int, required) – The size of spatial block.
  • data_format ({'NCHW', 'NHWC'}, optional) – The optional data format.
Returns:

dragon.Tensor – The output tensor.