How take weight values for P nad N in a BPN network for face recognition

1 view (last 30 days)
P=[196 35 234 232 59 244 243 57 226; ...
188 15 236 244 44 228 251 48 230; ...
246 48 222 225 40 226 208 35 234]'; ...
% testing images
N=[196 35 234 232 59 244 243 57 226; ...
188 15 236 244 44 228 251 48 230; ...
246 48 222 225 40 226 208 35 234]';...
% N=[208 16 235 255 44 229 236 34 247; ...
% 245 21 213 254 55 252 215 51 249; ...
% 248 22 225 252 30 240 242 27 244]'; ...
% Normalization
P=P/256;
N=N/256;
% display the training images
% targets
img=[196 35 234;
232 59 244 ;
243 57 226]';
T=img/256;;
% targets
% T=[0.8 0.06 0.9;
% 0.9 0.17 0.8;
% 0.9 0.13 0.9];
S1=90; % number of hidden layers
S2=3; % number of output layers (= number of classes)
can anyone explain me how here we have taken the values of image matrix(P,N) and why do we need to normalize it?

Accepted Answer

Greg Heath
Greg Heath on 21 Mar 2012
Normalization helps to prevent large signals from causing bounded activation functions in the first hidden layer ( like tansig and logsig) from operating in the asymptotic end regions where derivatives are so small that training may be stalled.
Keeping singals in the "active" nonasymptotic regime also helps numerical stability (See the comp.ai.neural-nets FAQ ).
What you have written in your post is very confusing.
How many classes, c do you have?
How large are your training and test sets?
[I Ntrn] = size(xtrn) % I = 9?
[O Ntrn] = size(ttrn) % O = c
[I Ntst] = size(xtst)
[O Ntst] = size(ttst)
Are the columns in your target matrices columns from the c-dimensional unit matrix eye(c)?
The number of training equations is Neq = Ntrn*O
For a I-H-O node topology the number of unknown weights is Nw = (I+1)*H+(H+1)*O.
If you are training to convergence, Neq >= Nw is required but Neq >> Nw is desired to mitigate measurement errors and noise in addition to obtaining good generalization with performance on nontraining data. The first requirement yields the following upper bound on the number of hidden nodes, H.
Hub = floor((Neq-O)/(I+O+1))
The second requirement yields H << Hub.
If you need a larger value of H to obtain satisfactory performance, use "Early Stopping" with a validation set and/or use regulatization with the objective function MSEREG.
Hope this helps.
Greg

More Answers (0)

Community Treasure Hunt

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

Start Hunting!