'Layer 1' is not a valid model name because it is not a valid MATLAB function name
83 次查看(过去 30 天)
显示 更早的评论
mar gian
2019-4-29
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
采纳的回答
Fangjun Jiang
2019-4-29
编辑:Fangjun Jiang
2019-4-29
remove the white space. call it "Layer1" or "Layer_1"
13 个评论
mar gian
2019-4-29
编辑:mar gian
2019-4-30
As I wrote its a automated generated neural network ...this is how I generate the model
[x,t] = engine_dataset;
trainRatio = 0.8; valRatio = 0; testRatio = 0.2;
[trainInd, valInd, testInd] = dividerand(size(x, 2), trainRatio, valRatio, testRatio);
% Train the a 2-layerd neural network with 10 neurons in the hidden layer
% using training data
net = fitnet(10);
net = train(net,x(:, trainInd),t(:, trainInd));
so how can I remove the white spaces? or better how can I rename it ??
p.s I did search before I post here.
UPDATE: I did found how to just change th block names..and I feel stupid because all it took was just a double-click on the name. Now when I tried to run it it shows an error of" Layer_1" is not loaded. I guess I should change it elsewhere too except just on the diagram. But I have really no clue where!
mar gian
2019-5-1
The R2018a . Is there any relation with the errors that appear? A common problem or something?
Fangjun Jiang
2019-5-1
I have R2018b. Running the above code brings up a GUI. I don't know what you mean by model or block.
mar gian
2019-5-1
yes. as I wrote in the UPDATE section this code generates my neural network. After that with the command
[model_name, net_name] = gensim(net, 'Name', 'myNeural');
I am generating a simulink model . I am referring to the blocks there. My bad I put simulink on tags and nowhere else. So the thing is I found a way to rename the autogenerated blocks on my model (only by double clicking on the name) in simulink, but I should propably change it somewhere else too because it gives me an error for example : the block 'Layer_1' is not loaded.
I dont know where though!
Fangjun Jiang
2019-5-1
There is no error in R2018b. I saw the block "Layer 1" and "Layer 2" but it simulates and no error.
Check the value of net.layers{1}.name and net.layers{2}.name. In R2018b, it is "Hidden" and "Output". It seems unrelated.
Might be a bug on the Mathworks side. Contact the technical support.
mar gian
2019-5-1
Hidden and Output is to my version as well.....I think it make some sense since Layer 1 is the hidden layer and layer 2 results the output. So i dont think there is my problem .
If I rename my blocks from "Layer 1" to "Layer1" should i just double click the name and change it or should I do something else too?
P.SThanks for taking the time to help me!
Fangjun Jiang
2019-5-2
Got it run in R2018a. Model is generated and simulates. No error. Post your model if you still have issues.
mar gian
2019-5-2
This is what I am getting after renaming from "Layer 1" to "Layer_1" . If I dont change anything I get : 'Layer 1' is not a valid model name because it is not a valid MATLAB function name.
![Screenshot (27).png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/217727/Screenshot%20(27).png)
Walter Roberson
2019-5-3
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.
Fangjun Jiang
2019-5-3
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.
mar gian
2019-5-4
"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 !!!!!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning with GPU Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)