MATLAB Answers

0

'Layer 1' is not a valid model name because it is not a valid MATLAB function name

Asked by mar gian on 29 Apr 2019
Latest activity Commented on by mar gian on 4 May 2019
What does it mean is not a valid MATLAB function name? When I first generated a neural network with matlab 'Layer 1' name was autogenerated. How can i resolve this ? If I rename somehow the block name is enough or this may mean something else too?
Thanks in advance,
M

  0 Comments

Sign in to comment.

Products


Release

R2018a

1 Answer

Answer by Fangjun Jiang on 29 Apr 2019
Edited by Fangjun Jiang on 29 Apr 2019
 Accepted Answer

remove the white space. call it "Layer1" or "Layer_1"

  12 Comments

The space is inserted at roughly line 338 of gensim, in the block of code that starts with the comment 'Network Block Names'. sprintf('Layer %g', i) . There is nothing you could do at the user level to designate a different name. You could probably create some code to change the block names.
If you examine
you will see that spaces are permitted in block names except as the first character of the name.
Now, model names have to be valid MATLAB function names, but layer names are block names, not model names.
Perhaps you are attempting to somehow invoke a layer directly as-if it were a model? For example you cannot open_system() a block directly: you have to open_system() the block qualified by the model name.
The error message come from fxpoptdemo_neuralnetworks_script.m. It is looking for root level model "Layer_1" and block "Layer_1/tansig", which don't exist.
Using gensim() as it is, there is a block 'myNeural/Function Fitting Neural Network/Layer 1/tansig'. Using this in your script should get rid of this error.
"Perhaps you are attempting to somehow invoke a layer directly as-if it were a model? For example you cannot open_system() a block directly: you have to open_system() the block qualified by the model name"
Yes, I went through the code again and I found out that I had done this exact thing...
And even I renamed the block when autogenerated it kept showing errors. Anyway I changed that and now works fine.
MANY THANKS to both of you who responded and spend some amount of time !!!!!

Sign in to comment.