tf.space_to_depth 函数
space_to_depth(input, block_size, data_format=“NHWC”, name=None):
将 height
和 width
维度的值重新排列到depth
维度。block_size
表示输入的块大小。block_size能整除
height 和 width 。
data_format
:
“NHWC”: [ batch, height, width, channels ]
“NCHW”: [ batch, channels, height, width ]
“NCHW_VECT_C”: qint8 [ batch, channels / 4, height, width, 4 ]
输入形状为 [n, h, w, c]
, data_format = “NHWC” 和block_size = bs,则
输出形状为 [n, h/bs, w/bs, c*bs*bs]
, data_format = “NHWC”
例如, 对于一个给定输入,形状为 [1, 2, 2, 1]
, data_format = “NHWC” 和block_size = 2:
x = [[[[1], [2]],
[[3], [4]]]]
这个运算会输出一个张量,形状为 [1, 1, 1, 4]
:
[[[[1, 2, 3, 4]]]]
相似的, 输入形状为 [1 4 4 1]
, block size 为 2:
x = [[[[1], [2], [5], [6]],
[[3], [4], [7], [8]],
[[9], [10], [13], [14]],
[[11], [12], [15], [16]]]]
输出形状 [1 2 2 4]
:
x = [[[[1, 2, 3, 4],
[5, 6, 7, 8]],
[[9, 10, 11, 12],
[13, 14, 15, 16]]]]