space_to_depth

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

Rearrange blocks of spatial data into depth.

Examples:

n, c, h, w, bs = 1, 2, 2, 2, 2
x = dragon.arange(n * c * h * w).reshape((n, c, h, w))
y = dragon.reshape(x, (n, c, h // bs, bs, w // bs, bs))
y = dragon.transpose(y, (0, 3, 5, 1, 2, 4))
y = dragon.reshape(y, (n, c * (bs ** 2), h // bs, w // bs))
z = dragon.nn.space_to_depth(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.