- 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
조회 수: 7 (최근 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!