I have a measurement variable a (1, 5) that I want to “alternate” as many times as the size of my mini-batch. For example, if the mini-batch size is 32, then I want to build a tensor c dimension (32, 5), where each row has values that are the same as the original (1, 5) variable a .
But I only know the mini-batch size at runtime: this is the dimension size 0 placeholder b : tf.shape(b)[0]
Here is my code for building c:
a = tf.Variable(np.random.uniform(size=(1,5))) b = tf.placeholder(shape=[None, 12], dtype=tf.float32) batch_size = tf.shape(b)[0] c = tf.tile(a, tf.pack([batch_size, 1]))
This is normal. However, c.get_shape() returns (?,?). I do not understand why this is not coming back (?, 5).
This causes a problem later in my code when I build the matrix variable W with the number of columns c.get_shape()[1] , which I expect to return 5, not ?.
Any help would be greatly appreciated. Thanks.
source share