Display output from neural network on APP Designer

1 visualización (últimos 30 días)
Aditi Mahajan
Aditi Mahajan el 27 de Abr. de 2023
Comentada: Aditi Mahajan el 5 de Mayo de 2023
I have build a neural network model and saved it to load in APP Designer as shown in figure.
The code is showing no error. But also, it doesn't display the output as required. I have singularly checked each code line's execution in live script and all is working fine. The saved model (MSB.mat) is also being loaded and working fine.
What could be the possibility of no output?
Kindly help!
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: CheckforsuitablematrixButton
function CheckforsuitablematrixButtonPushed(app, event)
% Input variables from the user (Process,Country,FTr,FWf,FAR,TS,TM,FS,FM)
Process=[app.ManufacturingProcessDropDown.Value]
Country=[app.GeographicalLocationDropDown.Value]
FWf=[app.FiberWeightFractionEditField.Value]
FAR=[app.FiberAspectRatioEditField.Value]
TS=[app.TensileStrengthMPaEditField.Value]
TM=[app.TensileModulusGPaEditField.Value]
FS=[app.FlexuralStrengthMPaEditField.Value]
FM=[app.FlexuralModulusGPaEditField.Value]
if strcmp(app.FiberTreatmentDropDown.Value,'Untreated')
FTr=[0];
else
FTr=[1];
end
% Aggregating input variables into a table named IP
IP=table(Process,Country,FTr,FWf,FAR,TS,TM,FS,FM)
% Loading the trained neural network
load MSB.mat
% Predicting the output from the input
Pred_M=predict(MSB,IP)
% Displaying the output
app.UsethegivenMatrixEditField.Value=Pred_M
end
end

Respuestas (1)

VBBV
VBBV el 27 de Abr. de 2023
Editada: VBBV el 27 de Abr. de 2023
%Loading the trained neural network
mdl = load('MSB.mat')
% Predicting the output from the input
Pred_M=predict(mdl,IP.Process)
Check the syntax for using the predict function
  12 comentarios
VBBV
VBBV el 30 de Abr. de 2023
ok, do you still get error ? can you share the code ?
Aditi Mahajan
Aditi Mahajan el 5 de Mayo de 2023
properties (Access = private)
Process
Country
FTr
FWf
FAR
TS
TM
FS
FM
IP % Description
end
% Callbacks that handle component events
methods (Access = private)
% Value changed function: ManufacturingProcessDropDown
function ManufacturingProcessDropDownValueChanged(app, event)
app.Process=string(app.ManufacturingProcessDropDown.Value);
end
% Value changed function: FiberWeightFractionEditField
function FiberWeightFractionEditFieldValueChanged(app, event)
value=app.FiberWeightFractionEditField.Value;
% Normalizing
app.FWf=(value-5)/45;
end
% Value changed function: FiberAspectRatioEditField
function FiberAspectRatioEditFieldValueChanged(app, event)
value=app.FiberAspectRatioEditField.Value;
% Normalizing
app.FAR=(value-3.15)/996.85;
end
% Value changed function: FiberTreatmentDropDown
function FiberTreatmentDropDownValueChanged(app, event)
if strcmp(app.FiberTreatmentDropDown.Value,'Untreated')
app.FTr=0;
else
app.FTr=1;
end
end
% Value changed function: GeographicalLocationDropDown
function GeographicalLocationDropDownValueChanged(app, event)
app.Country=app.GeographicalLocationDropDown.Value;
end
% Value changed function: TensileStrengthMPaEditField
function TensileStrengthMPaEditFieldValueChanged(app, event)
value=app.TensileStrengthMPaEditField.Value;
% Normalizing
app.TS=(value-1.62)/49.753;
end
% Value changed function: FlexuralStrengthMPaEditField
function FlexuralStrengthMPaEditFieldValueChanged(app, event)
value=app.FlexuralStrengthMPaEditField.Value;
% Normalizing
app.FS=(value-2.06)/104.34;
end
% Value changed function: TensileModulusGPaEditField
function TensileModulusGPaEditFieldValueChanged(app, event)
value=app.TensileModulusGPaEditField.Value;
% Normalizing
app.TM=(value-0.0834)/4.0006;
end
% Value changed function: FlexuralModulusGPaEditField
function FlexuralModulusGPaEditFieldValueChanged(app, event)
value=app.FlexuralModulusGPaEditField.Value;
% Normalizing
app.FM=(value-0.187)/4.913
end
% Button pushed function: CheckforsuitablematrixButton
function CheckforsuitablematrixButtonPushed(app, event)
% Loading classification neural network
net=load('MSB.mat');
% Aggregating input variables into a table named IP
app.IP=table('Size',[1 9], ...
'VariableTypes',{'categorical','categorical','double','double','double','double','double','double','double'}, ...
'VariableNames',net.MSB.PredictorNames);
app.IP.Process(1)=categorical(app.Process);
app.IP.Country(1)=categorical(app.Country);
app.IP.FTr(1)=app.FTr;
app.IP.FWf(1)=app.FWf;
app.IP.FAR(1)=app.FAR;
app.IP.TS(1)=app.TS;
app.IP.TM(1)=app.TM;
app.IP.FS(1)=app.FS;
app.IP.FM(1)=app.FM;
% Predicting the output from the input
Pred_M=predict(net.MSB,app.IP);
% Displaying the output
app.UsethegivenMatrixEditField.Value=char(Pred_M);

Iniciar sesión para comentar.

Categorías

Más información sobre Training and Simulation en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by