Welcome to our Support Center

DepthToSpace

Description

DepthToSpace rearranges (permutes) data from depth into blocks of spatial data.

 

 

This is the reverse transformation of SpaceToDepth. More specifically, this op outputs a copy of the input tensor where values from the depth dimension are moved in spatial blocks to the height and width dimensions. By default, mode = DCR. In the DCR mode, elements along the depth dimension from the input tensor are rearranged in the following order: depth, column, and then row. The output y is computed from the input x as below:

b, c, h, w = x.shape
tmp = np.reshape(x, [b, blocksize, blocksize, c // (blocksize**2), h, w])
tmp = np.transpose(tmp, [0, 3, 4, 1, 5, 2])
y = np.reshape(tmp, [b, c // (blocksize**2), h * blocksize, w * blocksize])

In the CRD mode, elements along the depth dimension from the input tensor are rearranged in the following order: column, row, and the depth. The output y is computed from the input x as below :

b, c, h, w = x.shape
tmp = np.reshape(x, [b, c // (blocksize ** 2), blocksize, blocksize, h, w])
tmp = np.transpose(tmp, [0, 1, 4, 2, 5, 3])
y = np.reshape(tmp, [b, c // (blocksize ** 2), h * blocksize, w * blocksize])


Input parameters

 

specified_outputs_namearray, this parameter lets you manually assign custom names to the output tensors of a node.
input (heterogeneous) – T : object, input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

 Parameters : cluster,

blocksize : integer, blocks of [blocksize, blocksize] are moved.
Default value “0”.
mode : enum, DCR for depth-column-row order re-arrangement. Use CRD for column-row-depth order.
Default value “DCR”.
 training? : boolean, whether the layer is in training mode (can store data for backward).
Default value “True”.
 lda coeff : float, defines the coefficient by which the loss derivative will be multiplied before being sent to the previous layer (since during the backward run we go backwards).
Default value “1”.

 name (optional) : string, name of the node.

Output parameters

 

 output (heterogeneous) – T : object, output tensor of [N, C/(blocksize * blocksize), H * blocksize, W * blocksize].

Type Constraints

T in (tensor(bfloat16)tensor(bool)tensor(complex128)tensor(complex64)tensor(double)tensor(float)tensor(float16)
tensor(int16)tensor(int32)tensor(int64)tensor(int8)tensor(string)tensor(uint16)tensor(uint32)tensor(uint64)tensor(uint8)) : Constrain input and output types to all tensor types.

Example

All these exemples are snippets PNG, you can drop these Snippet onto the block diagram and get the depicted code added to your VI (Do not forget to install Deep Learning library to run it).
Table of Contents