i am in the process of learning neural networks using MATLAB, i'm trying implement a face recognition program using PCA for feature extraction, and a feedforward neural network for classification.
i have 3 people in my training set, the images are stored in 'data' directory.
i am using one network for each individual, and i train each network with all the images of my training set, the code for my project is presented below:
dirs = dir('data');
size = numel(dirs);
eigenVecs = [];
% a neural network for each individual
net1 = feedforwardnet(10);
net2 = feedforwardnet(10);
net3 = feedforwardnet(10);
% extract eigen vectors and prepare the input of the NN
for i= 3:size
eigenVecs{i-2} = eigenFaces(dirs(i).name);
end
trainSet= cell2mat(eigenVecs'); % 27X1024 double
% set the target for each NN, and then train it.
T = [1 1 1 1 1 1 1 1 1 ...
0 0 0 0 0 0 0 0 0 ...
0 0 0 0 0 0 0 0 0];
train(net1, trainSet', T);
T = [0 0 0 0 0 0 0 0 0 ...
1 1 1 1 1 1 1 1 1 ...
0 0 0 0 0 0 0 0 0];
train(net2, trainSet', T);
T = [0 0 0 0 0 0 0 0 0 ...
0 0 0 0 0 0 0 0 0 ...
1 1 1 1 1 1 1 1 1];
train(net3, trainSet', T);
after finishing with training the network, i get this panel:
** if anyone could explain to me the progress section of the panel, because i could not understand what those numbers meant. **
after training the networks, i try to test the network using the following:
sim(net1, L)
where L is a sample from my set which is a 1X1024 vector, the result i got is this :
Empty matrix: 0-by-1024
is my approach to training the neural networks wrong ? what can i do to fix this program ?
thank you
The code
train(net1, trainSet', T);
does not save the trained network into the net1
variable (it saves it into ans
variable). This is the reason why the result of sim
is empty: there is no trained network in net1
. You have to save the trained network yourself:
net1= train(net1, trainSet', T);