title: Python - LSTM based RNN required 3D input?
body: <p>i am trying to build a deep learning network based on LSTM RNN here is what is tried</p>
  
  <pre><code>from keras.models import Sequential
  from keras.layers import Dense, Dropout, Activation
  from keras.layers import Embedding
  from keras.layers import LSTM
  import numpy as np
  
  train = np.loadtxt("TrainDatasetFinal.txt", delimiter=",")
  test = np.loadtxt("testDatasetFinal.txt", delimiter=",")
  
  y_train = train[:,7]
  y_test = test[:,7]
  
  train_spec = train[:,6]
  test_spec = test[:,6]
  
  
  model = Sequential()
  model.add(LSTM(32, input_shape=(1415684, 8),return_sequences=True))
  model.add(LSTM(64, input_dim=8, input_length=1415684, return_sequences=True))
  ##model.add(Embedding(1, 256, input_length=5000))
  ##model.add(LSTM(64,input_dim=1, input_length=10, activation='sigmoid',
  ##               return_sequences=True, inner_activation='hard_sigmoid'))
  model.add(Dropout(0.5))
  model.add(Dense(1))
  model.add(Activation('sigmoid'))
  
  model.compile(loss='binary_crossentropy', optimizer='rmsprop')
  
  model.fit(train_spec, y_train, batch_size=2000, nb_epoch=11)
  score = model.evaluate(test_spec, y_test, batch_size=2000)
  </code></pre>
  
  <p>but it gets me the following error</p>
  
  <pre><code>ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (1415684, 1)
  </code></pre>
  
  <p>Here is a sample from the dataset</p>
  
  <p>(Patient Number, time in millisecond, accelerometer x-axis,y-axis, z-axis,magnitude, spectrogram,label (0 or 1))</p>
  
  <pre><code>1,15,70,39,-970,947321,596768455815000,0
  1,31,70,39,-970,947321,612882670787000,0
  1,46,60,49,-960,927601,602179976392000,0
  1,62,60,49,-960,927601,808020878060000,0
  1,78,50,39,-960,925621,726154800929000,0
  </code></pre>
  
  <p>in the dataset i am using the only the spectrogram as input feature and the label (0 or 1) as the output the total traing samples is 1,415,684</p>