title: Tensorflow ValueError: Dimension 0 in both shapes must be equal, but are 344 and 2. From merging shape 0 with other shapes
body: <p>I am currently working on my bachelor thesis. The goal is to train a LSTM to seperate instruments in a given piece of music. Therefore I input a signal which gets processed by a Short-term Fourier Transform, which outputs an array of windows with complex values for every frequency. This array is then put into a Placeholder. I am currently unsure what the Input Dimension should be in [Batch Size, Sequence Length, Input Dimension] I just put in 1. The following is an excerpt of my code.</p>
  
  <pre><code>num_hidden,numFreqs=1024
  numWindows=344
  
  input_data = tf.placeholder(tf.float32,[numWindows,numFreqs,1])
  target_data = tf.placeholder(tf.float32,[numWindows,numFreqs,1])
  
  cell = tf.nn.rnn_cell.LSTMCell(num_hidden, forget_bias=1.0)
  
  val = tf.nn.dynamic_rnn(cell, input_data, dtype=tf.float32)
  
  weight = tf.Variable(tf.truncated_normal([numFreqs,num_hidden])) 
  bias = tf.Variable(tf.truncated_normal([num_hidden]))
  
  prediction = tf.add(tf.mul(val,weight),bias)
  
  cost = tf.reduce_mean(tf.square(prediction - target_data))
  
  optimizer = tf.train.AdamOptimizer(learning_rate)
  minimize = optimizer.minimize(cost)
  
  mistakes = tf.not_equal(tf.argmax(target_data, 1), tf.argmax(prediction, 1))     
  error = tf.reduce_mean(tf.cast(mistakes, tf.float32))
  </code></pre>
  
  <p>I get this error in the prediction line when I run it</p>
  
  <pre><code>ValueError: Dimension 0 in both shapes must be equal, but are 344 and 2
  From merging shape 0 with other shapes.
  </code></pre>
  
  <p>numWindows has the value 344 so the input_data placeholder is affected. But I cannot find the other shape which is causing the problem. The weight and bias variables have shapes [1024,1024] and [1024] so I was thinking that they cannot be the problem. If you need more information I am happy to give it to you.</p>