快速反卷积

1
2
3
4
5
6
7
8
9
10
11
12
def UnPooling2x2ZeroFilled(x):
# ('>>> x', TensorShape([Dimension(2), Dimension(16), Dimension(16), Dimension(256)]))
out = tf.concat(axis=3, values=[x, tf.zeros_like(x)])
out = tf.concat(axis=2, values=[out, tf.zeros_like(out)])

sh = x.get_shape().as_list()
if None not in sh[1:]:
out_size = [-1, sh[1] * 2, sh[2] * 2, sh[3]]
return tf.reshape(out, out_size)
else:
sh = tf.shape(x)
return tf.reshape(out, [-1, sh[1] * 2, sh[2] * 2, sh[3]])
请作者喝一杯咖啡☕️