- If your original data is in a 2D matrix of size (numSamples, numFeatures), reshape it into a 3D tensor of size (numSamples - windowSize + 1, windowSize, numFeatures). This creates the sliding window sequences.
- Change the inputSize property of the sequenceInputLayer to [windowSize, numFeatures]. This tells the layer to expect matrix inputs with the specified dimensions.
how to apply sliding window in deep learning LSTM
39 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi All,
i am currenty using MATLAB Deep Learning Toolbox to build a LSTM-Network to do timeseries regression. Since my data has 12 features and 1 response. The input size of the sequenceInputLayer is set to 12. However, i want to apply a sliding window to my data, which means the dimension of the input of the sequenceInputLayer should be a matrix. (if sliding window is 3,then the input should be [12*3] or [3*12] Matrix?) Is that possible and how to realize it? And also, how does Matlab know that the input data is time series?
Layers = [ ...
sequenceInputLayer(numFeatures)
gruLayer(numHiddenUnits,'OutputMode','sequence')
dropoutLayer(0.5)
fullyConnectedLayer(64)
dropoutLayer(0.5)
fullyConnectedLayer(numResponses)
regressionLayer];
0 Kommentare
Antworten (1)
prabhat kumar sharma
am 23 Jan. 2024
Hi Tony,
Yes, it's possible to apply a sliding window to your data and use a matrix as input for the sequenceInputLayer.
You can do the following updates.
layers = [ ...
sequenceInputLayer([windowSize, numFeatures])
... % Rest of your code
];
MATLAB doesn't inherently know that your data is time series. It treats it as a 3D tensor with dimensions corresponding to samples, timesteps, and features.
The LSTM and GRU layers are designed to handle sequential data, so they can learn temporal patterns within your time series.
I hope it helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!