title: Dimension Mismatch in LSTM Keras
body: <p>I want to create a basic RNN that can add two bytes. Here are the input and outputs, which are expected of a simple addition</p>
  
  <pre><code>X = [[0, 0], [0, 1], [1, 1], [0, 1], [1, 0], [1, 0], [1, 1], [1, 0]]
  </code></pre>
  
  <p>That is, <code>X1 = 00101111</code> and <code>X2 = 01110010</code></p>
  
  <pre><code>Y = [1, 0, 1, 0, 0, 0, 0, 1]
  </code></pre>
  
  <p>I created the following sequential model</p>
  
  <pre><code>model = Sequential()
  model.add(GRU(output_dim = 16, input_length = 2, input_dim = 8))
  model.add(Activation('relu'`))
  model.add(Dense(2, activation='softmax'))
  model.compile(loss = 'binary_crossentropy', optimizer = 'adam', metrics = ['accuracy'])
  model.summary()
  </code></pre>
  
  <p>The error I get is something along </p>
  
  <blockquote>
    <p>expected <code>lstm_input_1</code> to have 3 dimensions, but got array with shape <code>(8L, 2L)</code></p>
  </blockquote>
  
  <p>So if I increase the dimensions by changing X to </p>
  
  <pre><code>[[[0 0]] [[1 1]] [[1 1]] [[1 0]] [[0 0]] [[1 0]] [[0 1]] [[1 0]]]
  </code></pre>
  
  <p>Then the error changes to </p>
  
  <blockquote>
    <p>expected <code>lstm_input_1</code> to have shape <code>(None, 8, 2)</code> but got array with shape <code>(8L, 1L, 2L)</code></p>
  </blockquote>