Invalid training data. Sequence responses must have the same sequence length as the corresponding predictors.
4 次查看(过去 30 天)
显示 更早的评论
numFeatures = 1024;
numClasses = 249;
layers1 = [ ...
sequenceInputLayer(numFeatures,'Name','sequence')
fullyConnectedLayer(400,'Name','fc1')
reluLayer('Name','relu1')
fullyConnectedLayer(400,'Name','fc2')
reluLayer('Name','relu2')
fullyConnectedLayer(numClasses,'Name','fc3')
softmaxLayer('Name','sm')
classificationLayer('Name','class')];
miniBatchSize = 120;
numObservations = numel(TrC1);
numIterationsPerEpoch = floor(numObservations / miniBatchSize);
options1 = trainingOptions('adam', ...
'MiniBatchSize',miniBatchSize, ...
'MaxEpochs',12, ...
'InitialLearnRate',0.0001, ...
'L2Regularization', 0.000001, ...
'GradientThreshold',2, ...
'Shuffle','never', ...
'ValidationData',{VC1',ValidL}, ...
'ValidationFrequency',numIterationsPerEpoch, ...
'SquaredGradientDecayFactor',0.99, ...
'Plots','training-progress', ...
'Verbose',false);
lt=Trainlbl(1:14000);
net11 = trainNetwork(TrC1,TrainL,layers1,options1);
I am using a deep neural network. When I am running the code I am getting an error saying "Invalid training data. Sequence responses must have the same sequence length as the corresponding predictors". I am attaching the screenshot of the error.
In the workspace I have underlined the TrC1 and TrainL. I am not getting any clue right now. I have searched the solutions on mathworks, but it couldn't help me out.
In case you need the details or if you have any query, feel free to comment.
0 个评论
回答(1 个)
Tomaso Cetto
2021-9-30
Hi Navneet,
The issue here is that, when setting up a sequence-to-sequence problem (as it seems you are doing here), the number of time-steps of any input sequence needs to be equal to the number of time-steps of its corresponding output response sequence.
I'd need to see inside your TrC1 and TrainL cell arrays to investigate, but I imagine that each cell inside TrC1 is a numFeatures (1024) x T array, and each cell inside TrainL is a numClasses (249) x T array. One way or another, the T of TrC1(N) needs to be equal to the T of TrainL(N).
The easiest way to the do this is manually, using the padSequences function. This function will take in as input your entire cell array - you can use it to pad the sequences in a variety of ways.
Once the sequence lengths of the predictor sequences and the response sequences match up, your network should be good to train! Let me know if this works, and if I can help any further.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!