Thanks @Peter Hawkins for a great answer. In many cases, an extra step of changing the shape is required to add batch_size as the first dimension. I added an optional extra step that changes the tensor:
import tensorflow as tf import numpy as np batch_dependent_tensor = tf.placeholder(tf.float32, shape=[None, 3]) other_tensor = tf.constant([2, 3]) y = tf.tile(other_tensor, tf.shape(batch_dependent_tensor)[0:1])
Note that if other_tensor has a rank> 1 (is it a matrix or tensor with a larger dimension), then some changes to the code need to be made.
source share