MATLAB Answers

Problem with feedforwardnet function: not enough input arguments

14 views (last 30 days)
Pedro Gilabert
Pedro Gilabert on 17 Oct 2020
Edited: Adam Danz on 19 Oct 2020
I've been having recently some problems when creating neural networks on matlab. Basicaly, I cannot create a simple net due to the following problem: "not enough input arguments".
Previously it worked just fine. I used nntool and nnstart in order to create some backpropagation nets or the feedforwardnet function without any problem. But now, by just writting net=feedforwardnet or net=feedforwardnet("number of hidden layers") the software answers me with the previous message. I uninstalled and reinstalled the software in order to see if magically the problem would be fixed. And surprisingly it worked... for a day. So I don't know what else can I do, I hope someone could help me to solve this weird problem.
The complete outcome of matlab is the following:
>> net=feedforwardnet(2); (2 hidden layers for example)
Not enough input arguments.
Error in mse (line 2)
mseValue = mean((ytrue-ypred).^2,"omitnan");
Error in network>new_network (line 142)
net.performParam = mse('defaultParam');
Error in network (line 71)
net = new_network(varargin{:});
Error in feedforwardnet>create_network (line 105)
net = network;
Error in feedforwardnet (line 73)
net = create_network(param);

  0 Comments

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 17 Oct 2020
Edited: Adam Danz on 17 Oct 2020
Going all the way back to Matlab r2015b (the earliest version that provides access to documentation), feedforwardnet has always been defined with two inputs.
What release were you using that allowed you to use 0 or 1 input? Are you sure you weren't using a 3rd party function not provided by Matlab?
Update:
Now that I've had a chance to poke around in feedforwardnet.m, I notice that the function can receive 1 or even 0 inputs but this is not documented. Typically when inputs are optional the Matlab documentation will appear as below but this is either undocumented or inconsistent. When I try the function with 0 or 1 input in r2020b, I do not get an error.
Syntax
net = feedforwardnet blah blah blah blah
net = feedforwardnet(hiddenSizes) blah blah blah blah
net = feedforwardnet(hiddenSizes,trainFcn) blah blah blah blah

  2 Comments

Pedro Gilabert
Pedro Gilabert on 17 Oct 2020
Yeah, the function is feedforwardnet('hiddenSizes','trainFcn') which hiddenSizzes refers to the number of neurons in the hidden layers and trainFcn refers to the training mode that the net will use.
But, in the case that you don't especify those values the program assumes as default 10 hidden neurons and trainlm as the training process.
And I am pretty sure that I am using MATLAB R2020B from the beginning.
Adam Danz
Adam Danz on 17 Oct 2020
I've updated my answer.
When I try the function with r2020b with 1 input I do not get an error.
To check your matlab version, look at the top of the main command window or use ver().
Please share the entire error message.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!