Too many Arguments for trainNetwork()

13 views (last 30 days)
Aleks Boehler
Aleks Boehler on 27 Jan 2022
Answered: Benjamin Thompson on 27 Jan 2022
Hello Matlab Community,
I'm trying to make a neural network that identifies if the system is in one of two conditions ('Normal' or 'Slugged'- Condition) of a Data Set with Data Points of 13 sensors.
I have a Training Data Set with the size 9 600 000x 14. After I devided it into a Training and a Test set I got 'X_Train' of the size of 13x8640000 for the Input and 'Y_Train' of the size of 1x8640000 for the output. The rest goes into the Training Data Set. For better visualisation:
  • Main Data Set 'Gesamttabelle' : 9600000x14
  • Training Input 'X_Train': 13x864000
  • Training Output 'Y_Train': 1x864000
  • Test Input 'X_Test': 13x960000
  • Test Output 'Y_Test': 1x96000
That' how I coded the Data Set Editing:
load Gesamttabelle;
%% NN TRAINING/ TEST DATA SET
Data_Set_Shuffled = Gesamttabelle(randperm(size(Gesamttabelle,1)),:);
output = Data_Set_Shuffled(:,14);
output = table2array(output);
input = Data_Set_Shuffled(:,1:13);
% Switch Rows and Coloums
input = rows2vars(input);
output = output';
input(:,1) = [];
% Devide Data Set into Training and Test Sets
test_range = round(0.9*size(input,2),-2);
X_Train = input(1:13,1:test_range);
Y_Train = categorical(output(1:test_range));
X_Test = input(1:13,test_range:end);
Y_Test = categorical(output(test_range:end));
After that I designed the neurals network architecture and the training parameters
%% DEEP LEARNING NETWORK ARCHITECTURE
hidden_layer_size = 100;
layers = [...
sequenceInputLayer(13)
fullyConnectedLayer(hidden_layer_size)
reluLayer
fullyConnectedLayer(hidden_layer_size)
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
%% TRAINING PARAMETER
Batch_Size = 1000;
Epochs = 50;
options = trainingOptions('adam', ...
'MaxEpochs',Epochs, ...
'MiniBatchSize',Batch_Size, ...
'GradientThreshold',1, ...
'InitialLearnRate',0.001, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',125, ...
'LearnRateDropFactor',0.2, ...
'Verbose',0, ...
'Plots', 'training-progress',...
'ExecutionEnvironment','cpu');
Now, when I try to call the the trainNetwork()- function
NN = trainNetwork(X_Train,Y_Train,layers,options);
I get the Error message:
Error using trainNetwork (line 184)
Too many input arguments.
Error in SuO_NN_Train (line 93)
SuO_NN_raw = trainNetwork(X_Train,Y_Train,layers,options);
Caused by:
Error using nnet.internal.cnn.trainNetwork.DLTInputParser>iParseInputArguments (line 83)
Too many input arguments.
I use MATLAB R2021a. Can anybody please help me out?

Answers (1)

Benjamin Thompson
Benjamin Thompson on 27 Jan 2022
See the MATLAB help article on "Support Variable Number of Inputs", you probably want to use varargin. Also "Parse Function Inputs".

Community Treasure Hunt

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

Start Hunting!

Translated by