Back-propagation algorithm
Show older comments
clear all close all
PATTERNS=[[0.1 0.1 0.13 0.0 0.11 0.15 0.12 0.1 0.01 0.2 0.1 0.1 0.13 0.0 0.11 0.15 0.12 0.1 0.01 0.2];[0.5 0.45 0.6 0.55 0.45 0.55 0.44 0.48 0.5 0.44 0.5 0.45 0.6 0.55 0.45 0.55 0.44 0.48 0.5 0.44];[1 0.9 0.95 1 1 0.9 0.95 .94 1 0.9 1 0.9 0.95 1 1 0.9 0.95 .94 1 0.9]]' %TARGET = [0 0 0 0 0 0 0 0 0 0;0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5;1 1 1 1 1 1 1 1 1 1]; TARGET = [1 0 0;0 1 0;0 0 1] %TARGET = eye(3,3); % Desired output
[g,h]=size(PATTERNS); [m,h]=size(TARGET);
% CREATING and INITIATING THE NETWORK net = newff(minmax(PATTERNS),[5 3],{'logsig','logsig'},'traingdx'); net = init(net); net.LW{2,1} = net.LW{2,1}*0.03; net.b{2} = net.b{2}*0.03;
% TRAINING THE NETWORK net.trainParam.goal = 0.0001; % Sum-squared error goal. net.trainParam.lr = 0.01;% Learning Rate net.trainParam.show = 1; % Frequency of progress displays (in epochs). net.trainParam.epochs = 3000; % Maximum number of epochs to train. net.trainParam.mc = 0.3; % Momentum Factor.
[net,tr] = train(net,PATTERNS,TARGET)
% TEST PATTERNS_TEST=[0.1 0.2 0.15 0.0 0.1 0.1 0.2 0.1 0.13 0.12 0.1 0.2 0.15 0.0 0.1 0.1 0.2 0.1 0.13 0.12;0.5 0.4 0.53 0.55 0.45 0.5 0.4 0.48 0.5 0.44 0.5 0.4 0.53 0.55 0.45 0.5 0.4 0.48 0.5 0.44;1 0.9 0.95 1.05 1 0.9 0.95 1.04 1 0.9 1 0.9 0.95 1 1 0.9 0.95 .94 1 0.9]; for k=1:3 PATTERNS_TEST(:,k); FACE = sim(net,PATTERNS_TEST(:,k)) end
1 Comment
Answers (0)
Categories
Find more on Pattern Recognition 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!