I\'m searching for a tensorflow python method to enlarge (resize) a tensor to double every element in each feature map along both axis e.g.:
a = tf.convert_to_tensor([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
b = tf.reshape(a, [3, 3, 1])
c = tf.tile(b, [1, 1, 2])
d = tf.reshape(c, [3, 6])
print(d.eval())
array([[1, 1, 2, 2, 3, 3],
[4, 4, 5, 5, 6, 6],
[7, 7, 8, 8, 9, 9]], dtype=int32)
e = tf.reshape(d, [3, 6, 2])
f = tf.tile(e, [1, 1, 2])
g = tf.transpose(f, [0, 2, 1])
print(g.eval())
array([[[1, 1, 2, 2, 3, 3],
[1, 1, 2, 2, 3, 3]],
[[4, 4, 5, 5, 6, 6],
[4, 4, 5, 5, 6, 6]],
[[7, 7, 8, 8, 9, 9],
[7, 7, 8, 8, 9, 9]]], dtype=int32)
h = tf.reshape(g, [6, 6])
print(h.eval())
array([[1, 1, 2, 2, 3, 3],
[1, 1, 2, 2, 3, 3],
[4, 4, 5, 5, 6, 6],
[4, 4, 5, 5, 6, 6],
[7, 7, 8, 8, 9, 9],
[7, 7, 8, 8, 9, 9]], dtype=int32)
You can get a shape of the a
tensor (if it's defined) using:
shape = a.get_shape().as_list()