title: Fit the LSTM model in Python using Keras
body: <p>First of all, I have just stepped in deeplearing. And I want to use LSTM (in python, using Keras libraries) to solve the prediction problem.</p>
  
  <p>I have read the <strong>dataset</strong> (25 observations) from csv and splited it into 2 parts called: <strong>train</strong> set (67% of dataset, 17 observations) and <strong>test</strong> set (33% of dataset, 8 observations).</p>
  
  <p>I have changed <strong>train</strong> set into 2 set:</p>
  
  <ul>
  <li>trainX: [[obs[1], 0] [obs[2], 0] ... [obs[n-1], 0]]</li>
  <li>trainY: [[obs[2], 0] [obs[3], 0] ... [obs[n], 0]]</li>
  </ul>
  
  <p>(with n is the size of <strong>train</strong> set (17 observations))</p>
  
  <p>(i have done the same thing with <strong>test</strong> set)</p>
  
  <p>So, I have 4 set named: trainX, trainY, testX, textY</p>
  
  <p>Each set has the shape like [x[i], 0]</p>
  
  <p>I have read some "Google" document that i need to reshape it, so i do something like this:</p>
  
  <pre><code>trainX = numpy.reshape(trainX, (trainX.shape[0], 1, trainX.shape[1]))
  testX = numpy.reshape(testX, (testX.shape[0], 1, testX.shape[1]))
  </code></pre>
  
  <p>After 2 lines code, my trainX will be like [value[i], time_steps=1, value[i + 1]] </p>
  
  <p>(time_steps = look_back = 1)</p>
  
  <p>Then i print my shape to check how it look:</p>
  
  <pre><code>print(trainX.shape)
  </code></pre>
  
  <p>My shape is:</p>
  
  <pre><code>(15, 1, 2)
  </code></pre>
  
  <p>At last, before I make predictions, I need to fit the model so I do this:</p>
  
  <pre><code>model = Sequential()
  model.add(LSTM(4, input_shape=(1, look_back)))
  
  model.add(Dense(1))
  
  model.compile(loss='mean_squared_error', optimizer='adam')
  model.fit(trainX, trainY, epochs=100, batch_size=1, verbose=2)
  </code></pre>
  
  <p>(Actually, I don't know how to fit the model rightly, so it tell me the error).</p>
  
  <p>It notice the error:</p>
  
  <pre><code>ValueError: Error when checking input: expected lstm_0_input to have shape (None, 1, 1) but got array with shape (15, 1, 2)
  </code></pre>
  
  <p>Could you tell me the way how i can fit the model with my data sets?</p>
  
  <p>Thank you very much.</p>