MATLAB Answers

0

Neural Network in Matlab App Designer

Asked by Justin Primero on 12 Feb 2019
Latest activity Edited by Kojiro Saito on 9 Nov 2019
Is it possible to incorporate a Neural Network into an app created from the Matlab App Designer?

  6 Comments

Hi.
I wil try use the recomendation.
first, i used starupTcn(app) to load de net model. its call netdia.mat:
properties(Access = private)
net;
Y_predict;
end
function startupFcn(app)
app.net.net = load("C:\Predictor Demanda S.N.I\net\netdia.mat");
app.net = app.net.net;
end
then, into de code i tried to call de net with "YPred = predict(app.net, input);", like that:
Y_predict = predict(app.net,Xp_prediccion);
but, i got this error:
Undefined function 'predict' for input arguments of type
'struct'.
Error in
Predictor_Demanda_SNI_Corto_Plazo3/ProcesaDIASIGUIENTEButtonValueChanged
(line 336)
Y_predict =
predict(app.net,Xp_prediccion) % el
modelo previamente entrenado
únicamente generará la salida
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 378)
Error while evaluating StateButton PrivateValueChangedFcn.
what is my error?
thanks
The structure to be input in predict might be different.
How about changing as the follows?
function startupFcn(app)
app.net = load("C:\Predictor Demanda S.N.I\net\netdia.mat");
app.net = app.net.net;
end
If the above does not work, add a breakpoint in the line of
Y_predict = predict(app.net,Xp_prediccion);
and pause at this line. Then, what is a variable type of app.net? You can konw the variable type by whos command.
Thanks a lot. It works ok 👍

Sign in to comment.

2 Answers

Answer by Kojiro Saito on 12 Feb 2019
 Accepted Answer

Yes, Neural Network (both shallow and deep neural networks) works with applications created by AppDesigner both for training and predict. Could you specify your use case, if possible?

  3 Comments

I'm creating a graph through the use of a photorestistor operated by an Arduino. I would then extract numerical voltage values of the graph and record specific points of it in an excel file. The values would then be processed in a trained neural network for it to classify the graph that I generated. Is this possible? If so, how can I call a neural network into the AppDesigner?
Thank you for sharing your use case. Yes, it is possible in AppDesigner apps.
Here is one solution.
1. Train a neural network model and save the model as a mat file (for example, net.mat)
2. In AppDesigner, create a Private Property(net).
3. In a startup function, load the mat file and set as app.net.
net = load('net.mat');
app.net = net.net;
4. In a function callback which processes graph data (inputData), use classfiy with neural network.
[YPred, scores] = classify(app.net, inputData);
This has been very helpful. Thanks a lot, Kojiro Saito.

Sign in to comment.


Answer by Pablo Salaverria on 10 Jun 2019

Dear all,
while creating an app using app designer I am not able to compeltelly deploy my trainned CNN. My main issue is wiht the function classify which should be valid with:
[YPred]= classify(app.net,app.imds1);
Where app.net is the trainned CNN, app.imds1 is the imageDatastore where all the images that I want to classify are stored.
The error message that I got is:
Error using classify (line 123)
Requires at least three arguments.
Meaning that the function classify is using a 2nd options instead of the one that I want it to use. Is there a way to make it work?

  1 Comment

I have just answered your question in this link. Please take a look.

Sign in to comment.