 # How to model the data using LSTM

I have a sequence data like

``````X1, X2, X3, X4, X5 -> y1,y2,y3,y4,y5
X6,X7,X8 -> y6, y7, y8
``````

Where Xi is m x n dimension matrix, n is the number of columns (features in my data, which is same in all matrices Xi), whereas m is no of rows that varies. yi is the class label of size 1 x 1. I try to elaborate my problem with the help of diagram, in which X is 4D input matrix and Y is 2D output matrix.

It seems to me many-to-one architecture, where a matrix Xi outputs one class label yi, e.g (X1 -> y1). Length of sequence also varies, e,g first sequence has length 5 (X1, X2, X3, X4, X5), and second sequence has length 3 (X6,X7,X8). No of examples (rows) also varies in each instance of a sequence. E,g X1 has 20 rows, X2 has 30 rows etc.

My questions is

1- Do I need make the lengths of all sequences equals? If maximum sequence has length 5, then I should make all sequences of lengths 5 by padding with 0 value. Can this be solved using DLS?

2- What would be shape of input and output for LSTM?

3- As the nature of data is sequential, so I though LSTM is more useful for this purpose. Can this problem be handled only using LSTM, or I need to used other architectures as well?

1 Like

Hi

1. Yes length of the sequence should be same in DLS so you can add 0 padding in the end.
Next DLS supports multi input and single output
so you can have N length sequence input for output you need to append then into single column by separating values using “,”
Next yes LSTM would be a good option for this you can refer to this article.
https://link.medium.com/Km5a6NNnMW

Regards
Rajat

Hi,

How I can access your article?

https://link.medium.com/Km5a6NNnMW
error 410 !!!

Hi,
There is some issue with my account.
It will get resolve soon.