Too many input arguments.

14 views (last 30 days)
Chandini Govind
Chandini Govind on 10 Jan 2020
Edited: Kenan on 17 Jun 2022
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
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.

Sign in to comment.

Accepted Answer

Adam Danz
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:
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.
  9 Comments
Chandini Govind
Chandini Govind on 14 Jan 2020
because i'm getting the following error and couldn't resolve it.
Error using trainNetwork (line 150)
Invalid training data. Predictors must be a N-by-1 cell array of sequences, where N is the number of sequences. All
sequences must have the same feature dimension and at least one time step.
Error in study8 (line 37)
net = trainNetwork(ft,yy,layers,options);
Kenan
Kenan on 17 Jun 2022
Edited: Kenan on 17 Jun 2022
For information there is an example for this method :

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!