TensorFlow concat a variable-sized placeholder with a vector

Viewed 10061

Let's say I have a placeholder

ph_input = tf.placeholder(dtype=tf.int32, [None, 1])

and a vector

h = tf.zeros([1,2], dtype=tf.int32)

In this example h is filled with zeros for simplicity but in the actual case it will be changed by other variables and will have different values.

I want to efficiently do a concat on ph_input and h on dimension 1 and get a new tensor with shape [None, 1+2]. Unfortunately concat needs all input tensors to have the same shape except the concat_dim, which my example does not meet.

I was considering expand h to the same shape as the data that feed to ph_input but am not exactly sure how to do that with the placeholder itself. If I get the shape from the input data directly then I guess it is not necessary to use the placeholder.

1 Answers
Related