I am new to machine learning and keras. I was trying to create a LSTM model for my classification problem but I received this error: (I got few samples from internet and tried to modify them)
ValueError: Input 0 is incompatible with layer sequential_1: expected shape=(None, None, 30), found shape=[None, 3, 1]This is what I need, I have a sequence like this 1,2,3,4 which 1,2,3 are my X_train and 4 is label(Y), so I mean timestep size is 3 and each has one feature only
I have 30 classes for my labels. So I expect the output to be one of these 30 classes. 64 is number of memory units.
this is my code
def get_lstm():
model = Sequential()
model.add(LSTM(64, input_shape=(3, 30), return_sequences=True))
model.add(LSTM(64))
model.add(Dropout(0.2))
model.add(Dense(30, activation='softmax'))
X_train = user_data[:, 0:3]
X_train = np.asarray(X_train).astype(np.float32)
X_train = np.reshape(X_train, (X_train.shape[0], X_train.shape[1], 1))
Y_train = user_data[:, 3]
Y_train = np.asarray(Y_train).astype(np.float32)
local_model = Mymodel.get_lstm()
local_model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=['accuracy'])
local_model.set_weights(global_weights)
local_model.fit(X_train, Y_train, batch_size=32,
epochs=1)
please let me know if you need more information or if it s not clear. I really need your help guys, thanks