def uppool(value, name='uppool'): # TODO TBD??
"""N-dimensional version of the unpooling operation from
https://www.robots.ox.ac.uk/~vgg/rg/papers/Dosovitskiy_Learning_to_Generate_2015_CVPR_paper.pdf
Note that the only dimension that can be unspecified is the first one (b)
:param name:
:param value: A Tensor of shape [b, d0, d1, ..., dn, ch]
:return: A Tensor of shape [b, 2*d0, 2*d1, ..., 2*dn, ch]
"""
with tf.name_scope(name) as scope:
sh = value.get_shape().as_list()
dim = len(sh[1:-1])
print(value)
out = (tf.reshape(value, [-1] + sh[-dim:]))
for i in range(dim, 0, -1):
# out = tf.concat(i, [out, tf.zeros_like(out)]) #original implementation added zeros
out = tf.concat([out, tf.identity(out)], i) # copies values
out_size = [-1] + [s * 2 for s in sh[1:-1]] + [sh[-1]]
out = tf.reshape(out, out_size, name=scope)
return out
评论列表
文章目录