I am developing LSTM network in that I am getting error as "Invalid training data. Sequence responses must have the same sequence length as the corresponding predictors"
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
clc
clear all
close all
XTrain = xlsread('R1_all_data.xlsx',1,'A1:G3788');
YTrain = xlsread('R1_all_data.xlsx',1,'H1:H3788');
XTest = xlsread('R2_all_data.xlsx',1,'A1:G3788');
YTest = xlsread('R2_all_data.xlsx',1,'H1:H3788');
inputSize = 3788;
numResponses = 1;
numHiddenUnits = 1000;
layers = [ sequenceInputLayer(inputSize)
lstmLayer(numHiddenUnits)
fullyConnectedLayer(numResponses)
regressionLayer ];
opts = trainingOptions('adam', 'MaxEpochs', 1000, 'GradientThreshold', 0.01, 'InitialLearnRate', 0.01);
net = trainNetwork(XTrain,YTrain,layers,opts);
YPred1=predict(net,XTest)
figure,
plot(YPred1,'r-*','LineWidth',1),hold on
plot(YTest,'g-*','LineWidth',1), hold all;
xlabel('sample')
ylabel('values')
grid on
legend('Predicted', 'Original ');
title('performance')
0 Commenti
Risposte (1)
Krishna
il 10 Feb 2024
Modificato: Krishna
il 10 Feb 2024
Hi PRAMOD,
It seems there's a misunderstanding in how you're utilizing the ‘sequenceInputLayer.’ The correct number of inputs for the sequence should be 7, not the 3788 you're currently using, which represents the count of your observations. Additionally, it's important to note that both the ‘sequenceInputLayer’ and the subsequent ‘lstmLayer’ are designed to accept only cell input arrays consisting of sequences.
So to give you an perspective they accept data in the format, axbxc where a are the number of sequences you have b is the number of feature in the sequence and c is the number of observation in that sequence.
Also, I noticed that you have not specified ‘sequence’ in lstmLayer. If you are doing sequence to sequence problem which I think you are doing seeing your dataset, please classify ‘sequence’ in ‘lstmLayer’.
For accurate implementation details, please consult the documentation for ‘sequenceInputLayer’ and ‘lstmLayer’,
https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.sequenceinputlayer.htmlhttps://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.lstmlayer.html
Also please go through the following example for detailed explanation on how to use these layers,
Hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Sequence and Numeric Feature Data Workflows in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!