tf.batch_to_space_nd()
参数:
tf.batch_to_space_nd(
input,
block_shape,
crops,
name=None
)
使用案例:
import tensorflow as tf
inputs = [[[[0], [1], [3]]], [[[0], [9], [11]]],
[[[0], [2], [4]]], [[[0], [10], [12]]],
[[[0], [5], [7]]], [[[0], [13], [15]]],
[[[0], [6], [8]]], [[[0], [14], [16]]]]
block_shape = [2, 2]
crops = [[0, 0], [0, 0]]
sess = tf.Session()
print(sess.run(tf.batch_to_space_nd(inputs, block_shape, crops)))
这个函数根据官方文档理解起来有点难,我花了几个小时才搞明白,它是根据block_size和crops两个参数决定最后转换的矩阵,拿上面例子来说:
官方给的公式为