I am getting this error while implementing LSTM in Keras:
""""Error when checking input: expected lstm_16_input to have 3 dimensions, but got array with shape (156060, 1)""""
I have 156060 text phrases all of different lengths, so I was trying to implement LSTM on it without padding. So at first I indexed all these phrases into numerical values and so I got an array of shape (156060,1) and I have labels of shape (156060, 5). Now I implemented my model like this:
model = Sequential() model.add(LSTM(64, input_shape = (156060,1), return_sequences=True)) model.add(Dense(5, activation= "softmax")) model.compile(optimizer = "adam", loss = "categorical_crossentropy", metrics = ["accuracy"]) model.summary() #encoded_docs.shape = (156060,1) and labels.shape = (156060,5) model.fit(encoded_docs, labels, epochs = 5)
I know there is some mistake in my input shape but I am unable to find it. If someone can explain me this, it will be a great help.