- 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
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
prabhat kumar sharma
2024-1-23
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!