- You have set “OutputMode="Sequence" for the "lstmLayer" generates an output for each time step in the input sequence.
- This implies that the "lstmLayer" takes an input sequence with "nInputSequence = 15" time steps and "nFeatures = 10" and produces "nInputSequence = 15" responses, each of size "nResponses = 1". For an input sequence of size 15x10, the output sequence will have a size of 15x1.
- However, the current output sequence has a size of 12x1, which is causing the error, since the network does not know how to handle the additional three-time steps in the input sequence.
- Additionally, note that while the number of time steps may vary between samples, the input and output sequences must have the same number of time steps.
Time series Sequence to Sequence regression dimensions
조회 수: 15 (최근 30일)
이전 댓글 표시
Hi all,
I am working on an application of time series regression/prediction using Sequence to Sequence concept. My data is generated from simulations, in which I have different operating points, generating time series. The inputs matrix, , has dimensions , and the outputs matrix, , has also dimensions .
I reorganize the data into sequences in the form of a cell array with size . Each sequence of has the dimensions of and the corresponding output sequence has the size . The and are not necessarily equal.
I followed the tutorial here: Sequence-to-Sequence Regression Using Deep Learning to create my network as follows:
inputSeqSize = 15;
outputSeqSize = 12;
nFeatures = 10;
nResponses = 1;
layers = [ ...
sequenceInputLayer(nFeatures)
lstmLayer(nHiddenUnits,OutputMode="sequence")
fullyConnectedLayer(50)
dropoutLayer(0.5)
fullyConnectedLayer(nResponses)];
with the following solver options:
maxEpochs = 60;
miniBatchSize = 20;
options = trainingOptions("adam", ...
MaxEpochs=maxEpochs, ...
MiniBatchSize=miniBatchSize, ...
InitialLearnRate=0.01, ...
GradientThreshold=1, ...
Shuffle="never", ...
Metrics="rmse", ...
Plots="training-progress", ...
Verbose=0);
predictor_net = trainnet(inputSeqsReduced,outputSeqsReduced,layers,"mse",options);
This is how my data looks like:
I receive the following error:
Error using trainnet (line 54)
Error evaluating loss function.
Error in VS_Predictor_Training (line 137)
predictor_net =
trainnet(inputSeqsReduced,outputSeqsReduced,layers,"mse",options);
Caused by:
Error using validateTrueValues (line 54)
Size of predictions and targets must match.
Size of predictions:
1(C) × 20(B) × 15(T)
Size of targets:
1(C) × 20(B) × 12(T)
I would appreciate your help regarding the error and the design of the network to fulfill the required task. Thanks!
Best
댓글 수: 0
답변 (1개)
Aastha
2024년 12월 2일
Hi Omar,
To resolve the error, you can consider the following changes to your network design:
To resolve this issue, you can:
1. Adjust the number of time steps in the output sequence to match the input sequence "nInputSequence = 15".
2. Introduce additional layers, such as an encoder layer, to compress the input sequence of length 15 into an output sequence of length 12.
I hope this helps!
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!