Clear Filters
Clear Filters

how to save result in matlab neural network 2023

13 views (last 30 days)
how to save result in matlab neural network 2023
  2 Comments
John D'Errico
John D'Errico on 26 Dec 2023
Highly confusing question. Do you have a neural network that you generated, and you want to know how to save it? Where? As a .mat file?
Or do you have something, that you want to somehow store as a neural network? Something else maybe?
alsayed almetwaly
alsayed almetwaly on 27 Dec 2023
yes i generate a neural network , and i want to save it

Sign in to comment.

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 27 Dec 2023
Understand what issue you are facing with the net() - neural network simulation. Here is one code automatically generated by MATLAB, and then I added a few lines to store data from simulations (see comments SAVE).
% X - input data.
% y - target data.
Compounds = {'pH', 'L*', 'a*', 'b*', 'SubColor', 'WBSF1', 'WBSF2', 'WBSF3', 'WBSF4', 'WBSF5', 'WBSF5', 'WBSF_ave'};
N = 1; % 1 = pH; 2 = L*; 3 = a*; 4 = b*; 5 = SubColor; 6:11 = WBSF1:6; 12 = WBSF_ave
disp(['Simulation of: ' Compounds{N}]);
x = INALL(); x=x'; % Input: predictor data set
t = normalize(RALL(:,N), 'norm'); t=t'; % Output Data set
%t = RALL(:,N); t=t';
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
trainFcn = 'trainbr'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.output.processFcns = {'removeconstantrows','mapminmax'};
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivision
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 80/100;
net.divideParam.valRatio = 10/100;
net.divideParam.testRatio = 10/100;
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = 'mse'; % Mean Squared Error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist','plotregression', 'plotfit'};
% Train the Network
[net,tr] = train(net,x,t);
TRn{N}=tr; % SAVE
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y);
PERFORn{N} = performance; % SAVE
% Recalculate Training, Validation and Test Performance
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y);
valPerformance = perform(net,valTargets,y);
testPerformance = perform(net,testTargets,y);
%
trainTARGETn{N}=trainTargets; % SAVE
valTARGETn{N}=valTargets; % SAVE
testTARGETn{N}=testTargets; % SAVE
trainPERFORn{N}=trainPerformance; % SAVE
valPERFORn{N}=valPerformance; % SAVE
testPERFORn{N}=testPerformance; % SAVE
% View the Network
view(net)
MODELn{N}=net;
% figure(N), plotperform(tr)
% figure(N+1), plottrainstate(tr)
% figure(N+2), plotregression(t,y)
  1 Comment
alsayed almetwaly
alsayed almetwaly on 27 Dec 2023
not working
I am making demand forecasting with artificial neural networks with matlab 2023, but I cannot get estimated results,

Sign in to comment.

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!