train code of Neural Network Toolbox for GUI packaging

I'm using MATLAB 2017b and Appdesigner to make a GUI which contains 'train' code of Neural Network Toolbox. And I want to make the standalone execution program of it by using application compiler.
All lines are executable when I run on Appdesigner tool. However, after I make the standalone application, 'train' code is not executed (I made a button for executing train code).
So I wonder that it is possible to contain 'train' code in the standalone execution program.
Here are some lines of the GUI code.
----------------------------------------------------------------------------------------------------------------
function TrainButtonPushed(app, event)
if strcmp(app.TrainButton.Enable,'on')
app.TrainButton.Enable='off';
IN_IM_SEQ=app.data.IN_IM_SEQ;
OUT_SEQ=app.data.OUT_SEQ;
for j=1:6
c=train(app.net,IN_IM_SEQ,OUT_SEQ); % Training neural network
d=c(IN_IM_SEQ); % trained network ouptut
app.epochEditField.Value = j;
end
app.hb=[c.IW{1,1} c.b{1}]; % [h bias], 15 by 31
app.wb=[c.LW{2,1}'; c.b{2}];
app.net_trained=c;
app.net_out=d;
app.ExportTrainedNetworkButton.Enable='on';
app.net=[];
app.NeuralNetworkLamp.Color = [1,0,0];
app.TrainingDATALamp.Color = [1,0,0];
app.TrainedNetworkLamp.Color = [0,1,0];
end
end

7 Comments

Hi! Did you solve this? I have the same problem in my appdesigner standalone app. The button doesn't work in order to train the network :S
Hi Alvaro.
I solved this problem by simply adding a function 'fitnet'.
I guess MATLAB compiler includes neural network toolbox in the package only if the function 'fitnet' is used somewhere in the code.
So I wrote a useless line 'tmp=fitnet(10)' right before the 'for loop'.
I hope this would be helpful.
Hi Jaepil, thanks for answering.
I noticed that in your code you didn't call any kind of network before the training, so you had to add 'fitnet' like you said.
In my case I am using a feedforward network (not fitnet or patternnet) and I am calling the feedforwardnet function to initialize the network previous the training via:
net = feedforwardnet(hiddenLayerSize,trainingFunction);
Just as it happened to you, from appdesigner everything works correctly so I don't understand it stops working when I make the deploy :(
Another related question, the appdesigner application deployed runs on a computer that does not have matlab installed?
Hi Alvaro.
The application deployed runs on the computer with MATLAB runtime which will be installed with your standalone application.
If you want to diagnose whether your code works well, I recommend building a very simple test GUI with GUIDE.
Then you can make an execution file by using the following code
mcc -m 'your_file_name.m'
After running the generated execution file, you will see some logs on the command windows which is gonna popped up with the execution.
In my case, I found that the neural network toolbox was not loaded into my standalone application. After adding the function 'fitnet', I found the app works well on a computer without Matlab installed.
you may refer to this site
https://kr.mathworks.com/help/nnet/ug/deploy-training-of-neural-networks.html
Thanks again for your response.
I've realize that my problem is because the training progress dialog, nntraintool is not supported in deployed mode :( so I can't show the training progress on the screen as it goes through the epochs.
Is there any way to catch the value of the epochs while the training process is running?
net.trainParam.showCommandLine = true;
With the previous command we can see the process through the matlab console, but in this case I need to show it through the GUI, so I need to catch the value of every epoch during the training to notice the user how much is left to reach the end.
Thanks Jaepil
I'm not sure if Neural network toolbox provides the iteration numbers during the training. You may edit the 'train' code for your purpose, although it can be quite a cumbersome task.
To see and edit 'train' function, we can use "Ctrl + D" on 'train' in your code.

Sign in to comment.

Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Asked:

on 8 May 2018

Commented:

on 15 Jun 2018

Community Treasure Hunt

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

Start Hunting!