tensorflow中tile是用来复制tensor的指定维度,具体看下面的代码:

import tensorflow as tf
 
a = tf.constant([[1, 2], [3, 4], [5, 6]], dtype=tf.float32)
 
a1 = tf.tile(a, [2, 2])
with tf.Session() as sess:
  print(sess.run(a1))

结果就是:

[[ 1. 2. 1. 2.]
 [ 3. 4. 3. 4.]
 [ 5. 6. 5. 6.]
 [ 1. 2. 1. 2.]
 [ 3. 4. 3. 4.]

 [ 5. 6. 5. 6.]]

因为

a1 = tf.tile(a, [2, 2]) 表示把a的第一个维度复制两次,第二个维度复制2次。