How to reshape the data for an LSTM from 252 entry and 14 features to 42 examples with 6 timesteps and 14 features?

4 visualizaciones (últimos 30 días)
Hi All,
I am very new to MATLAB and I am trying to replicated my LSTM code of Python in MATLAB. I am trying to work on a problem where for 6 days of values/inputs we get a single output. In python the data has been structured from (252,14) to (42,6,14) where 14 is the total features of the dataset, 6 are the timesteps and 42 are actual examples. The output is a 42,1 vector.
I tried to reshape the data in the same format of 42,6,14 but after running the network I keep getting this error:
Error using trainNetwork (line 183)
The training sequences are of feature dimension 42 6 but the input layer expects sequences of feature dimension 14.
Error in LSTM (line 40)
I will really appreciate if someone can give me some right path. Thanks in advance.

Respuestas (1)

Asvin Kumar
Asvin Kumar el 4 de En. de 2021
There’s a great example that should illustrate how to prepare your data. Please have a look at the Load Sequence Data section of the Sequence Classification Using Deep Learning example.
The attached doc uses the Japanese Vowels data set which has 270 examples with feature length of 12. These examples are of varying sequence lengths while in your case all the examples would have the same sequence length. You would have to convert your array into a cell array. Here’s a code snippet that should help get you on your way:
data = ones(42,6,14); % dummy data
data = permute(data, [3 2 1]);
data2 = num2cell(data, [1 2]);
data2 = permute(data2, [3 2 1]);

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by