how exactly to use the trainNetwork function?

4 次查看(过去 30 天)
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 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by