BP Neural Network

49 views (last 30 days)
Younes Jafari
Younes Jafari on 18 Apr 2012
Hi, I want to implement some custom BP Neural Networks with MATLAB! I have an aging database that contains face features (68 pairs of face points), gender and age. so I have a [1002x138] matrix as input datas for NN. 1002 face features and 138 value for each face...
face features must classify to 4 groups of ages [1-12,13-25,26-45,46-63] by NN.
Back-propagation network features : 136(68x2) Input values, 2 hidden layers, 4 output values (boolean type).
To achieve my target, I need to construct five NNs. The first NN is the main neural network. The main NN is concern with the main age classification with four outputs as I mentioned before. The other four NNs are concern with secondary age classification. Each neural network (the five networks) has 68 pairs of inputs representing the face features in addition to the gender of the person. It is also to be noted that we need two hidden layers, one hidden layer is to correlate each pair in one meaningful unit and the second is consider to be the real hidden layer after organizing the input data in the first hidden layer. The gender is connected directly to the second hidden layer. The number of outputs for each NN related to secondary classification is two representing the more specific age range in its domain.
I did read this article : (<http://web.eecs.umich.edu/~someshs/nn/matlab_nn_starter.htm>) but finally I've never been success in nnetwork creation.
It's my network definition :
net =network;
net.numInputs=138;
for i=1:136
net.inputs{i}.size = 1;
end
net.numLayers = 3;
net.layers{1}.size = 69;
net.layers{2}.size = 69;
net.layers{3}.size = 4;
net.inputConnect(1) = 1;
net.layerConnect(2, 1) = 1;
net.layerConnect(3, 2) = 1;
net.outputConnect(3) = 1;
net.targetConnect(3) = 1;
net.layers{1}.transferFcn = 'logsig';
net.layers{2}.transferFcn = 'purelin';
net.layers{3}.transferFcn = 'purelin';
net.biasConnect(1) = 1;
net.biasConnect(2) = 1; %how can I connect this bias to gender?
net.biasConnect(3) = 1;
net.initFcn = 'initlay';
net = init(net);
net.performFcn = 'mse';
net.trainFcn = 'trainlm';
I want to know how can I define, connect, train and test these networks using matlab?
Thanks guys.
  3 Comments
Greg Heath
Greg Heath on 18 Apr 2012
Have you considered k-means clustering, using a radial basis function net or using a LVQ net? These aproaches tend to allow a better visualization and understanding of the class division.
Hope this helps.
Greg
Younes Jafari
Younes Jafari on 26 Apr 2012
Hi Greg,
thanks for your comment.
I'm using Matlab 2011 NNToolbox. Put that nnetwork source code here please!

Sign in to comment.

Accepted Answer

Greg Heath
Greg Heath on 19 Apr 2012
If the net
1. MUST be a 2-hidden-layer FFMLP
2. MUST use the 1st hidden layer to recognizably separate the 4 classes
3. MUST be trained via BackProp
Try versions of the following:
1. For each class, design a 136-1-1 two-class classifier using patternnet(1). Since the initial weights are random, design many ( 10 each?) and choose the best.
2. Use the weights of the 4 selected classifiers for the first layer weights of a 136-4-4 four-class classifier using patternnet([4 H]).
3. Choose a good value for H by trial and error.
4. If you cannot freeze the 1st layer weights with learning rates of zero, store the hidden layer outputs of the two-class classifiers to train the last two layers of the four-class classifier.
Hope this helps.
Greg

More Answers (1)

Younes Jafari
Younes Jafari on 26 Apr 2012
Thanks Greg! Can you leave some code here? I'd edit my first post, please check it again. I want to know how can I implement your suggest?
please help me.

Community Treasure Hunt

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

Start Hunting!