Too many input arguments.
15 views (last 30 days)
Show older comments
clc;
close all;
clear all;
%load train dataset
train=xlsread('trainchanged.csv','A2:AG1000');
class_label=train(:,33);
%exclude eventid,weight from init_table
train_sample=train(:,2:31);
%appending class label
final_train=[train_sample class_label];
x=final_train(:,1:30);
xx=array2table(x);
yy=categorical(final_train(:,end));
%lstm definition
layers = [ ...
sequenceInputLayer(1)
bilstmLayer(100,'OutputMode','last')
fullyConnectedLayer(2)
softmaxLayer
classificationLayer
];
options = trainingOptions('adam', ...
'MaxEpochs',10, ...
'MiniBatchSize', 150, ...
'InitialLearnRate', 0.01, ...
'SequenceLength', 1000, ...
'GradientThreshold', 1, ...
'ExecutionEnvironment',"auto",...
'plots','training-progress', ...
'Verbose',false);
%train the network
net = trainNetwork(xx,yy,layers,options);
how to resolve the error: Too many input arguments.
5 Comments
Adam Danz
on 11 Jan 2020
"i know we can't run the code. i want know if it is due to some logical mistake."
@ Chandini Govind , I was able to identify the error because I happen to have r2018b on my laptop. Note that r2019b, the most recent release, does not have the same code for this function and we could not have identified the problem using the current release.
If you would have provided us with inputs, almost any experienced volunteer here could have instantly seen that your first input is a table while you're using numeric syntax. This is why it's almost always helpful to provide inputs that allow us to reproduce the problem.
Accepted Answer
Adam Danz
on 11 Jan 2020
Edited: Adam Danz
on 11 Jan 2020
Understand the input options
In your version of Matlab (r2018b) as well as in the current release (r2019b), there are multiple syntax options for this function that allow for various input types:
- image datastore inputs net = trainNetwork(imds,layers,options) 3 inputs
- datastore objects net = trainNetwork(ds,layers,options) 3 inputs
- numeric arrays net = trainNetwork(X,Y,layers,options) 4 inputs
- and tables net = trainNetwork(tbl,layers,options) 3 inputs
Your code uses the numeric input syntax
net = trainNetwork(xx,yy,layers,options);
where xx and yy are expected to be numeric arrays.
What does your error tell us?
Your error in r2018b is thrown at line 274 in trainNetwork().
Error using trainNetwork>iParseInputArguments (line 274)
That line is within a conditional statement that indicates that your first input xx is actually a table. As you can see in the image below. If you look at the "table" syntax above, you'll see that it only has 3 inputs.
Solution
Use the right syntax for tables.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!