title: How to explicitly broadcast a tensor to match another's shape in tensorflow?
body: <p>I have three tensors, <code>A, B and C</code> in tensorflow, <code>A</code> and <code>B</code> are both of shape <code>(m, n, r)</code>, <code>C</code> is a binary tensor of shape <code>(m, n, 1)</code>.</p>
  
  <p>I want to select elements from either A or B based on the value of <code>C</code>. The obvious tool is <code>tf.select</code>, however that does not have broadcasting semantics, so I need to first explicitly broadcast <code>C</code> to the same shape as A and B.</p>
  
  <p>This would be my first attempt at how to do this, but it doesn't like me mixing a tensor (<code>tf.shape(A)[2]</code>) into the shape list.  </p>
  
  <pre><code>import tensorflow as tf
  A = tf.random_normal([20, 100, 10])
  B = tf.random_normal([20, 100, 10])
  C = tf.random_normal([20, 100, 1])
  C = tf.greater_equal(C, tf.zeros_like(C))
  
  C = tf.tile(C, [1,1,tf.shape(A)[2]])
  D = tf.select(C, A, B)
  </code></pre>
  
  <p>What's the correct approach here?</p>