how i save this code please tell me?? with .mat

% Solve a Pattern Recognition Problem with a Neural Network
% Script generated by Neural Pattern Recognition app
% Created 28-Jun-2021 19:24:51
%
% This script assumes these variables are defined:
%
% inputs - input data.
% targetsd - target data.
x = inputs;
t = targetsd;
net = alexnet;
% 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 = 'trainscg'; % Scaled conjugate gradient backpropagation.
% Create a Pattern Recognition Network
hiddenLayerSize = 20;
net = patternnet(hiddenLayerSize, trainFcn);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotconfusion(t,y)
%figure, plotroc(t,y)

Answers (1)

You don't save code as a .mat file. Save it as .m or .mlx.
See Save and Back Up Code for more.
You can save variables in your workspace to a mat file. To do that, see the Save documentation page.

4 Comments

i save the variable x and t but i got error
variable x was not found
so what i do
Where do you try to save it? There is no save command in the code you have shared, and whenever you did try to save it, apparently the variable no longer existed.
the code is from neural network i train in matlab . i dont know how to save it or how to save the variables of it . so can you give some info about it .
to know how to save the trained neural network . i was work on handwritten recognition . and i can not able to run it .
"i save the variable x and t but i got error
variable x was not found"
How did you try to save variable x? What code or command produced this error?

Sign in to comment.

Categories

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

Asked:

on 28 Jun 2021

Edited:

on 29 Jun 2021

Community Treasure Hunt

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

Start Hunting!