I am trying to train a LSTM, but I have some problems regarding the data representation and feeding it into the model.
My data is a numpy array of three dimensions: One sample consist of a 2D matrix of size (600,5). 600(timesteps) and 5(features). However, I have 160 samples or files that represent the behavior of a user in multiple days. Altogether, my data has a dimension of (160,600,5).
The label set is an array of 600 elements which describes certain patterns of each 2D matrix. The shape of the output should be (600,1).
My question is how can I train the LSTM to the corresponding label set? What would be the best approach to handle this problem? The idea is that the output should be an array of (600,1) with 3 label inside.
Multiple_outputs {0,1,2}
Output: 0000000001111111110000022222220000000000000
-------------600 samples ------------------
Input: (1, 600, 5)
Output: (600, 1)
Training: (160,600,5)
I look forward for some ideas!
dataset(160,600,5)
X_train, X_test, y_train, y_test = train_test_split(dataset[:,:,0:4], dataset[:,:,4:5],test_size = 0.30)
model = Sequential()
model.add(InputLayer(batch_input_shape = (92,600,5 )))
model.add(Embedding(600, 128))
#model.add(Bidirectional(LSTM(256, return_sequences=True)))
model.add(TimeDistributed(Dense(2)))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy',
optimizer=Adam(0.001),
metrics=['accuracy'])
model.summary()
model.fit(X_train,y_train, batch_size=92, epochs=40, validation_split=0.2)