- If you specify sequences as a numeric or cell array, then you must also specify the responses argument.
how exactly to use the trainNetwork function?
4 views (last 30 days)
Show older comments
David Vatavu
on 4 Dec 2023
Commented: Cris LaPierre
on 5 Dec 2023
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
0 Comments
Accepted Answer
Cris LaPierre
on 4 Dec 2023
You need to include a response input.
2 Comments
Cris LaPierre
on 5 Dec 2023
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
More Answers (0)
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!