title: Tensorflow RNN shape mismatch- logits_size=[5,2] labels_size=[50,2] - Batch size is 10
body: <p>I'm working on a simple LSTM implementation in Tensorflow and having some trouble with the dimensions. So, my</p>
  
  <pre><code>batch size = 10
  time_steps = 5
  num_classes = 2 
  input_size = 4
  </code></pre>
  
  <p>The placeholders are </p>
  
  <p><code>x = tf.placeholder('float',[None,time_steps,input_size])</code></p>
  
  <p><code>y = tf.placeholder('float',[None,None,num_classes])</code></p>
  
  <p>I run it by feeding data from a csv file</p>
  
  <p><code>_, c = sess.run([optimizer, cost], feed_dict={x: _x, y: _y})</code>
  where I've set <code>_x.shape = (10, 5, 4)</code> and <code>_y.shape = (10, 5, 2)</code>
  in accordance with the <code>(batch,time_steps, input_size)</code> requirement of TF.</p>
  
  <p>I've gone through a few implementations(mostly on the MNIST dataset) on the internet and blog posts and I think I've understood how it works. TF expects the logits and labels arguments to be 2-D tensors with batch_size rows, and num_classes columns. Now, I have a classification label for each entry. I've converted them into the one-hot format. If I provide a total of 50 entries from the data, I should be providing 50 labels too, right?</p>
  
  <p>Changing the y placeholder to <code>[None,num_classes]</code> and consequently some other stuff also gave an error. </p>
  
  <p>But if I change my <code>batch_size</code> to 1, I can get the code to run, until the line </p>
  
  <p><code>correct = tf.equal(tf.argmax(prediction, 1), tf.argmax(y, 1))</code>
  where I get an error 
  <code>ValueError: Dimensions must be equal, but are 5 and 2 for 'Equal' (op: 'Equal') with input shapes: [5], [?,2].</code> 
  because prediction shape is <code>(5, 2)</code> whereas y is <code>(?, ?, 2)</code></p>
  
  <p>Is there a fundamental mistake in my understanding of how it should work?</p>
  
  <p>The full code can be viewed at <a href="https://gist.github.com/avi-jain/9e40c41a991041a45a2e24bd77de388c" rel="nofollow noreferrer">Simple RNN Gist</a></p>
  
  <p>Thanks</p>