|TensorFlow 1 version||View source on GitHub|
DepthToSpace for tensors of type T.
tf.nn.depth_to_space( input, block_size, data_format='NHWC', name=None )
Rearranges 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
dimension are moved in spatial blocks to the
block_size indicates the input block size and how the data is moved.
- Chunks of data of size
block_size * block_sizefrom depth are rearranged into non-overlapping blocks of size
block_size x block_size
- The width the output tensor is
input_depth * block_size, whereas the height is
input_height * block_size.
- The Y, X coordinates within each block of the output image are determined by the high order component of the input channel index.
- The depth of the input tensor must be divisible by
block_size * block_size.
data_format attr specifies the layout of the input and output tensors
with the following options:
[ batch, height, width, channels ]
[ batch, channels, height, width ]
qint8 [ batch, channels / 4, height, width, 4 ]
It is useful to consider the operation as transforming a 6-D Tensor. e.g. for data_format = NHWC, Each element in the input tensor can be specified via 6 coordinates, ordered by decreasing memory layout significance as: n,iY,iX,bY,bX,oC (where n=batch index, iX, iY means X or Y coordinates within the input image, bX, bY means coordinates within the output block, oC means output channels). The output would be the input transposed to the following layout: n,iY,bY,iX,bX,oC
This operation is useful for resizing the activations between convolutions (but keeping all data), e.g. instead of pooling. It is also useful for training purely convolutional models.
For example, given an input of shape
[1, 1, 1, 4], data_format = "NHWC" and
block_size = 2: