title: Keras LSTM Multiple Input Multiple Output
body: <p>I am trying to train an RNN to predict stock prices in the future.</p>
  
  <p>My goal is to train the model using two datasets: X_train and y_train.</p>
  
  <p>X_train is a 3D array including (number of observations, number of previous candles, attributes of each candle)</p>
  
  <p>y_train is a 3D array including (number of observations, number of observations in the future, price).</p>
  
  <p>So if I have data from 500 candles my X_train will be (430,60,6): for 430 observations (current candle each time) take the 60 observations that came before it and 6 characteristics (close price, volume, etc.) of them and try to use that data (through the RNN) to predict y_train(430, 10,1): for 430 observations predict the close price (corresponds to 1) for the next 10 candles.
  I cannot, for the life of me, get the dimensions to enter the model correctly.
  I use the following code for the model:</p>
  
  <pre><code>regressor = Sequential()
  
  regressor.add(LSTM(units = 50, return_sequences = True, input_shape = ( 
  X_train.shape[1], 6)))
  regressor.add(Dropout(0.2))
  
  regressor.add(LSTM(units = 50, return_sequences = True))
  regressor.add(Dropout(0.2))
  
  regressor.add(LSTM(units = 50, return_sequences = True))
  regressor.add(Dropout(0.2))
  
  regressor.add(LSTM(units = 50, return_sequences = True))
  regressor.add(Dropout(0.2))
  
  regressor.add(LSTM(units = 50, return_sequences=True))
  regressor.add(Dropout(0.2))
  
  regressor.add(LSTM(units = 1))
  
  regressor.compile(optimizer = 'adam', loss = 'mean_squared_error')
  regressor.fit(X_train, y_train, epochs = 20, batch_size = 32)
  </code></pre>
  
  <p>I get <code>ValueError: Error when checking target: expected lstm_6 to have 2 dimensions, but got array with shape (430, 10, 1)</code></p>
  
  <p>Thanks a lot.</p>