What arguments should I pass to input_shape parameter of LSTM function in Keras?

My dataset has 2944424 rows and 6 columns. I am using an LSTM in Keras to forecast taxi demand. I am having problem with the input_shape parameter of the LSTM.

It gives the error:

ValueError: Error when checking input: expected lstm_15_input to have 3 dimension

• Add your model code so that people can understand the process. – Peter Jun 16 '19 at 14:11

Input should be of shape (batch size, number of steps, features). See the following for details:

https://machinelearningmastery.com/reshape-input-data-long-short-term-memory-networks-keras/

Following example shows that by printing shape of your train data you can pass the right value to input_shape(). Also it depends you want to feed your data in 2D or another way. As it can be seen in snippet:

trainX.shape[1]=10

trainX.shape[2]=1440

and in output based on test shape Dense(units = 960)

#Shape of train and test data
trainX, testX, trainY, testY = train_test_split(trainX,trainY, test_size=0.2 , shuffle=False)
print("train size: {}".format(trainX.shape))
print("train Label size: {}".format(trainY.shape))
print("test size: {}".format(testX.shape))
print("test Label size: {}".format(testY.shape))
#train size: (23, 10, 1440)
#train Label size: (23, 960)
#test size: (6, 10, 1440)
#test Label size: (6, 960)

# create and fit the Simple LSTM model

#model_LSTM = Sequential()



Edit: Following tips based on this example to help you when preparing your input data for LSTMs:

• The LSTM input layer must be 3D.
• The meaning of the 3 input dimensions are: samples, time steps, and features.
• The LSTM input layer is defined by the input_shape argument on the first hidden layer.
• The input_shape argument takes a tuple of two values that define the number of time steps and features.
• The number of samples is assumed to be 1 or more.
• The reshape() function on NumPy arrays can be used to reshape your 1D or 2D data to be 3D.
• The reshape() function takes a tuple as an argument that defines the new shape.
• Trying your solution it says IndexError: tuple index out of range. – Saeed Ahmad Jun 16 '19 at 17:09
• I updated the answer but would you share your code so that we can have a look!? – Mario Jun 17 '19 at 16:11
• model.add(LSTM(50, activation='relu', input_shape=(3, 1))) This is throwing error. I am not getting that how should I change that? – Saeed Ahmad Jun 18 '19 at 5:44
• I guess that your input_shape is not right and you can't pass the right dimension. Plz update your question by leaving your complete code including dataset and data split and so on. – Mario Jun 18 '19 at 17:54