# Error: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=2

I am getting the error:

Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=2


Using the model:

X = np.reshape(x_train_tfidf.shape[0], 1, x_train_tfidf.shape[1])
print(X.shape)
input_shape=X))


• Have a look at your dimensions before building your network.. Apr 23, 2018 at 16:59
• @Aditya x_train_tfidf (35000,1000), x_test (15000,1000) Apr 23, 2018 at 17:21
• @Aditya so? you know? Apr 23, 2018 at 19:03
• With X = np.reshape(x_train_tfidf.shape[0], 1, x_train_tfidf.shape[1]) and input_shape=X, it looks like you are telling the LSTM layer that the input size is the input tensor itself, not its shape. docs.scipy.org/doc/numpy/reference/generated/numpy.reshape.html Sep 23, 2018 at 21:09

It's probably this way..(not sure , give it a try)

Iputs needs to be reshaped to be [samples, time steps, features]

so

TrainX= np.reshape(TrainX,(TrainX.shape[0], 1, TrainX.shape[1]))


You need to passin the actual vector also?

import numpy as np np.expand_dims(X, axis = 0)