MATLAB Answers

LSTM training problem in MATLAB

조회 수: 2(최근 30일)
Hossein Malekahmadi
Hossein Malekahmadi 2021년 7월 24일
댓글: Sruthi Gundeti 2021년 7월 26일
Hi i tried to run LSTM with below code and i dont know why i get this error
% Calculating amount of test data
N = round(size(inp_train,1)*30/100);%change 0.3 for defferent amount of test data
% Seperating data for training and testing
nn_train = inp_train(1:end-N,:);
in_test = inp_train(end+1-N:end,:);
tn_test = tar_train(end+1-N:end,:);
nn_target = tar_train(1:end-N,:);
numfeatures = size(nn_train,2);
numHiddenUnits = 100;
numClasses = size(nn_target,2);
layers = [...
maxEpochs = 1000;
options = trainingOptions('adam',...
'GradientThreshold', 0.01);
net = trainNetwork(nn_train, nn_target, layers, options);
the error:
Error using trainNetwork (line 150)
Invalid training data. Sequence responses must have the same sequence length as the corresponding
Error in LSTM (line 30)
net = trainNetwork(nn_train, nn_target, layers, options);
and my data:

채택된 답변

Sruthi Gundeti
Sruthi Gundeti 2021년 7월 26일
The LSTM network considers inputs as follows
No of rows= No of features
No of columns= No of Samples
No of samples for training data and target data must be same i.e., No of columns of NN_target and nn_train must be same
You can train by using transpose of both data
i.e.,net = trainNetwork(nn_train, nn_target, layers, options);
  댓글 수: 2
Sruthi Gundeti
Sruthi Gundeti 2021년 7월 26일
You are welcome 🙂

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by