title: TensorFlow: how to batch mut-mul a batch tensor by a weight variable?
body: <p>I have the following batch shape:</p>
  
  <pre><code> [?,227,227]
  </code></pre>
  
  <p>And the following weight variable:</p>
  
  <pre><code> weight_tensor = tf.truncated_normal([227,227],**{'stddev':0.1,'mean':0.0})
  
   weight_var = tf.Variable(weight_tensor)
  </code></pre>
  
  <p>But when I do <code>tf.batch_matmul</code>:</p>
  
  <pre><code> matrix = tf.batch_matmul(prev_net_2d,weight_var)
  </code></pre>
  
  <p>I fail with the following error:</p>
  
  <blockquote>
    <p>ValueError: Shapes (?,) and () must have the same rank</p>
  </blockquote>
  
  <hr>
  
  <p>So my question becomes: How do I do this?</p>
  
  <p>How do I just have a weight_variable in 2D that gets multiplied by each individual picture (227x227) so that I have a (227x227) output??  The flat version of this operation completely exhausts the resources...plus the gradient won't change the weights correctly in the flat form...</p>
  
  <hr>
  
  <p>Alternatively: how do I split the incoming tensor along the batch dimension (?,) so that I can run the <code>tf.matmul</code> function on each of the split tensors with my weight_variable?   </p>