Matlab Neural Network
Transcript of Matlab Neural Network
-
8/9/2019 Matlab Neural Network
1/9
January 2-, 2015, MATLAB Tutorial for ECE 614
Regression Using eural et!or"
1- Using eural et!or" #U$ %nnstart&
-
8/9/2019 Matlab Neural Network
2/9
2- Using Co''an(-Line fun)tions
% Solve an Input-Output Fitting problem with a Neural Network % Script generated by NFTOOL % % This script assumes these variables are defined % % houseInputs - input data! % houseTargets - target data!
load house"datasetinputs # houseInputs$targets # houseTargets$
% reate a Fitting Network hiddenLayerSi&e # '($net # fitnet)hiddenLayerSi&e*$
% Set up +ivision of +ata for Training, alidation, Testing net!divide.aram!train/atio # 0(1'(($net!divide.aram!val/atio # '21'(($net!divide.aram!test/atio # '21'(($
% Train the Network 3net,tr4 # train)net,inputs,targets*$
% Test the Network outputs # net)inputs*$errors # gsubtract)outputs,targets*$
performance # perform)net,targets,outputs*
% iew the Network view)net*
% .lots % 5ncomment these lines to enable various plots! % figure, plotperform)tr* % figure, plottrainstate)tr* % figure, plotfit)targets,outputs* % figure, plotregression)targets,outputs*
% figure, ploterrhist)errors*
-
8/9/2019 Matlab Neural Network
3/9
Classifi)ation Using eural et!or"
1- Using eural et!or" #U$ %nnstart&
-
8/9/2019 Matlab Neural Network
4/9
2- Using Co''an(-Line fun)tions
% Solve a .attern /ecognition .roblem with a Neural Network % Script generated by N./TOOL % % This script assumes these variables are defined % % cancerInputs - input data! % cancerTargets - target data!
inputs # cancerInputs$targets # cancerTargets$
% reate a .attern /ecognition Network hiddenLayerSi&e # '($net # patternnet)hiddenLayerSi&e*$
% Set up +ivision of +ata for Training, alidation, Testing net!divide.aram!train/atio # 0(1'(($net!divide.aram!val/atio # '21'(($net!divide.aram!test/atio # '21'(($
% Train the Network 3net,tr4 # train)net,inputs,targets*$
% Test the Network outputs # net)inputs*$errors # gsubtract)targets,outputs*$performance # perform)net,targets,outputs*
% iew the Network view)net*
% .lots % 5ncomment these lines to enable various plots! % figure, plotperform)tr* % figure, plottrainstate)tr* % figure, plotconfusion)targets,outputs* % figure, ploterrhist)errors*
-
8/9/2019 Matlab Neural Network
5/9
Clustering Using eural et!or" %*elf-+rganiing
Mas&
1- Using eural et!or" #U$ %nnstart&
2- Using Co''an(-Line fun)tions
-
8/9/2019 Matlab Neural Network
6/9
% Solve a lustering .roblem with a Self-Organi&ing 6ap % Script generated by NTOOL % % This script assumes these variables are defined % % simpleclusterInputs - input data!
load iris"dataset inputs # irisInputs$
% reate a Self-Organi&ing 6ap dimension' # '($dimension7 # '($net # selforgmap)3dimension' dimension74*$
% Train the Network 3net,tr4 # train)net,inputs*$
% Test the Network outputs # net)inputs*$
% iew the Network view)net*
% .lots % 5ncomment these lines to enable various plots! % figure, plotsomtop)net* % figure, plotsomnc)net*
% figure, plotsomnd)net* % figure, plotsomplanes)net* % figure, plotsomhits)net,inputs* % figure, plotsompos)net,inputs*
-
8/9/2019 Matlab Neural Network
7/9
E.a'les fro' t/e Te.t
1-igit ete)tion
%% data as in e!g! 8!'9, p! 228
digitsInput # 3!!!( ( ' ( ( !!! here goes the '( ( ' ( ( !!!( ( ' ( ( !!!( ( ' ( ( !!!
( ( ' ( (( ' ' ' ( !!! here goes the 7( ( ( ' ( !!!( ( ' ( ( !!!( ' ( ( ( !!!' ' ' ' '( ' ' ' ( !!!here goes the :( ( ( ' ( !!!( ( ' ' ( !!!( ( ( ' ( !!!( ' ' ' (( ' ( ( ' !!! ;( ' ( ( ' !!!( ' ' ' ' !!!( ( ( ( ' !!!( ( ( ( '( ' ' ' ( !!! 2( ' ( ( ( !!!( ' ' ' ( !!!( ( ( ' ( !!!( ' ' ' (4$
digitsInput#digitsInput
-
8/9/2019 Matlab Neural Network
8/9
%% plot the digitsfigure$for d#'2
subplot)',2,d*$imshow)reshape)digitsInput),d*,2,2*#(!8?sin)pi?=*$
%plot)=,>*
net#newfit)=,>,2*$net!divideFcn#,
-
8/9/2019 Matlab Neural Network
9/9
in#=Test),i*$myOut),i*#O@?tansig)B@?inGBC*GOC$% H input neuronsH% H output activation, no output sigmoid
end%postprocess the outputmyOut#mapminma)