Dynamically tile a tensor depending on the batch size
You can use tf.shape
to find out the runtime shape of a tensor, and use it as the basis for the argument to tf.tile
:
import tensorflow as tf
import numpy as np
x = tf.placeholder(tf.float32, shape=[None, 3])
y = tf.tile([2, 3], tf.shape(x)[0:1])
sess = tf.Session()
print(sess.run(y, feed_dict={x: np.zeros([11, 3])}))
I verified this code works with the Tensorflow 1.0 release candidiate. Hope that helps!