depth_to_space

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

Rearrange depth data into spatial blocks.

Examples:

n, c, h, w, bs = 1, 4, 1, 1, 2
x = dragon.range(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.
  • mode (str, optional, default='DCR') – Rearrangement order for 'NCHW' format.
  • data_format (str, optional, default='NCHW') – 'NCHW' or 'NHWC'.
  • copy (bool, optional, default=True) – Return a new tensor or call in-place.
Returns:

dragon.Tensor – The output tensor.