MATLAB: Create target for neural network

lbpneural network

Hi all,
I had extracted feature vector of an image and saved it in a excel document. feature vector is 42×42 dimension. I don't know how to create target for this input so i can train the neural network. I need to do emotion classification. 5 classes. So, how do i create target vector and train the network?

Best Answer

Hi, Remo
Feature vector that extracted from an image ideally m x 1 matrix.
You said that it's 42 x 42. Is it means 42 feature of 42 images??
If so, then you need to create 5 x 42 matrix of target.
First create matrix of zero 5 x 42.
for feature#1, this feature belong to which emotion? Let say 3rd class. Then you need to mark at first column 3rd row as 1.
t = [0 0 0 0 0 ... until 42
0 0 0 0 0 ...
1 0 0 0 0 ...
0 0 0 0 0 ...
0 0 0 0 0 ...
And so on.
I have an example below. In this example I have 5x5 feature vector. and 5x5 matrix of target.
p = [1 0 1 0 1
0 1 1 0 1
1 0 0 1 1
0 1 0 1 1
1 0 0 1 1];
t = [0 0 1 0 0
0 0 0 0 1
1 0 0 0 0
0 1 0 0 0
0 0 0 1 0];
PR = [0 1;0 1;0 1;0 1;0 1];
net = newff(PR,[5 25 25 5],{'logsig','logsig','logsig','logsig'},'traingda');
net.trainParam.epochs = 1500;
net.trainParam.goal = 0;
net = train(net,p,t);
Then try to simulate the first feature.
sim(net,p(:,1))
And the result :
ans =
0.0032
0.0003
0.9955
0.0000
0.0029
It means this inputs belong to 3rd class.
I hope this will helps.