我有一个张量为(1,4,4,1)的张量,我想重复此过程并将其形状增加为(1,28,28,1)。我想在每个维度上重复一遍。
答案 0 :(得分:0)
您可以使用tf.tile。这是一个带有较小张量的示例:
a = tf.constant([[[[1],[2]],[[3],[4]]]])
print(a.shape) # (1, 2, 2, 1)
b = tf.tile(a, [1,3,3,1])
print(b.shape) # (1, 6, 6, 1)
with tf.Session() as sess:
print(sess.run(b))
# [[[[1] [2] [1] [2] [1] [2]]
# [[3] [4] [3] [4] [3] [4]]
# [[1] [2] [1] [2] [1] [2]]
# [[3] [4] [3] [4] [3] [4]]
# [[1] [2] [1] [2] [1] [2]]
# [[3] [4] [3] [4] [3] [4]]]]