how exactly to use the trainNetwork function?

조회 수: 12 (최근 30일)
David Vatavu
David Vatavu 2023년 12월 4일
댓글: Cris LaPierre 2023년 12월 5일
I want to use the function net = trainNetwork(sequences,layers,options) like this to train a recurrent network of the form lstm for identifying nonlinear systems. I have for training two sets of input data and one set of output data.
numResponses=1;
featureDimension=1;
numHiddenUnits=70;
miniBatchSize=300;
maxEpochs=1000;
layer=[...
sequenceInputLayer(featureDimension)
lstmLayer(numHiddenUnits,'OutputMode','last')
dropoutLayer(0.02)
fullyConnectedLayer(numResponses)
regressionLayer
];
options=trainingOptions('adam',...
'MaxEpochs',maxEpochs,...
'MiniBatchSize',miniBatchSize,...
'GradientThreshold',20,...
'Shuffle','once', ...
'Plots','training-progress',...
'ExecutionEnvironment','parallel',...
'LearnRateSchedule','piecewise',...
'LearnRateDropPeriod',200,...
'L2Regularization',1e-3,...
'LearnRateDropFactor',0.5,...
'Verbose',0,...
'Plots','training-progress');
C = num2cell(table2array(x1_train));
net = trainNetwork(C',layer,options);
Here is a part of my code.x1_train is a variable that contains the u1 regressor for the 2 tank system and I transformed it into a cell array because I understood that I had to do so that I could use this data in the train network function and I got the following error:
Error using trainNetwork
Not enough input arguments.
Error in sperproiectfinal1 (line 84)
net = trainNetwork(C',layer,options);
Caused by:
Error using nnet.internal.cnn.trainNetwork.DLTInputParser>iParseInputArguments
Not enough input arguments.
please help me with some steps that I should follow to use the function properly and be able to train my network with two sets of input data and one set of output data

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 12월 4일
You need to include a response input.
From the documentation for sequence (Numeric or cell array row of the table) :
  • If you specify sequences as a numeric or cell array, then you must also specify the responses argument.
  댓글 수: 2
David Vatavu
David Vatavu 2023년 12월 5일
Hi Cris, thanks for your reply. But my question is: how do I find out variabla responses?
Cris LaPierre
Cris LaPierre 2023년 12월 5일
It should be part of your training data set. You need to create a 'labeled' data set for training.
When the input data is a numeric array or a cell array, specify the responses as one of the following.
  • categorical vector of labels
  • numeric array of numeric responses
  • cell array of categorical or numeric sequences

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by