titu1994 / MLSTM-FCN

Multivariate LSTM Fully Convolutional Networks for Time Series Classification
492 stars 180 forks source link

Input shape confusion #9

Closed sedghi closed 5 years ago

sedghi commented 5 years ago

Thanks for providing the code I'm a little bit confused about the input shape of the models. In the keras documentation it specifically says that the input shape for LSTM needs to be input_shape=(timesteps, data_dim) but in lots of models I'm seeing you have used shape=(MAX_NB_VARIABLES, MAX_TIMESTEPS) which is the transpose of what keras documentation says. Do you have any comment on this?

titu1994 commented 5 years ago

If you read the paper, you will find that we are applying dimension shuffle to the the LSTM pathway (Batch, Variables, Timesteps) and FCN pathway gets ordinary input (Batch, Timesteps, Variables).

In the code, we preprocess the input to be dimension shuffled from the beginning, therefore the input shape is (Batch, Variables, Timesteps) and we perform the dimension shuffle on the FCN pathway instead. The two operations are interchangeable.

sedghi commented 5 years ago

I see, In the paper it says: In the proposed model, the dimension shuffle operation is only applied when the number of time steps, N, is greater than the number of variables, M. That's why I was confused as in my data I have N<M Thanks for the prompt reply