|TensorFlow 1 version||View source on GitHub|
SpaceToDepth for tensors of type T.
tf.nn.space_to_depth( input, block_size, data_format='NHWC', name=None )
Rearranges blocks of spatial data, into depth. More specifically,
this op outputs a copy of the input tensor where values from the
width dimensions are moved to the
block_size indicates the input block size.
- Non-overlapping blocks of size
block_size x block sizeare rearranged into depth at each location.
- The depth of the output tensor is
block_size * block_size * input_depth.
- The Y, X coordinates within each block of the input become the high order component of the output channel index.
- The input tensor's height and width must be divisible by 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,oY,bY,oX,bX,iC (where n=batch index, oX, oY means X or Y coordinates within the output image, bX, bY means coordinates within the input block, iC means input channels). The output would be a transpose to the following layout: n,oY,oX,bY,bX,iC
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, 2, 2, 1], data_format = "NHWC" and
block_size = 2:
x = [[[, ], [, ]]]
This operation will output a tensor of shape
[1, 1, 1, 4]:
[[[[1, 2, 3, 4]]]]
Here, the input has a batch of