Recurrent networks for facial recognition

1 次查看(过去 30 天)
HI, I'm trying to make a face recognition using wavelets and recurrent neural network, I'm new to the neural netwoks domain so I need help, I searched for this type of networks (recurrent nn) but I didn't really undertand how to create, train, and simulate one, I tried many codes that didn't work, I'm having a hard time figuring out what data to put in the parameters, to train or to simulate the net, SO pleaase can anyone tell me if recurrent neural network are good for face recognition? and if so which one of recurrent nn is better? and what implmentation of code can work for me ? please I need help ASAP
I've done this with mlp and it worked: I have two codes one to create the network and the other uses the network to calculate FAR, I wanna to do the same thing with a recurrent network
I'm trying LSTM now, but I always have this error :
Error using trainNetwork (line 154)
Invalid training data. Responses must be a vector of categorical responses, or a cell array of categorical response sequences.
Please can anyone help!
function [ net ] = createlstmcat( P, T)
input = P;
targets = T;
numFeatures = 199;
numHiddenUnits = 100;
numClasses =200;
layers = [ ...
sequenceInputLayer(numFeatures)
lstmLayer(numHiddenUnits,'OutputMode','last')
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
maxEpochs = 100;
miniBatchSize = 27;
options = trainingOptions('adam', ...
'ExecutionEnvironment','cpu', ...
'GradientThreshold',1, ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'SequenceLength','longest', ...
'Shuffle','never', ...
'Verbose',0, ...
'Plots','training-progress');
net = trainNetwork(input,targets,layers,options);
%%%%%%% to find identification rate
nbr_sujet=40;
classe=nbr_sujet;
x=[];
pcatrain = load ('.\\Resultat_pca_train\\pcatrain.fp');
pcatest = load ('.\\Resultat_pca_test\\pcatest.fp');
MatTrain = vec2mat(pcatrain, 199)';
MatTest = vec2mat(pcatest, 199)';
image=5;
class=[];
m=1;
for i=1:image:image*classe
for j=1:5
class=[class m] ; % classes
end
m=m+1;
end
%%%%inputs and targets normalization %%%%
pt= MatTrain;
v=pt(:);
b = max([v;1]);
a = min( [v;-1]);
for j=1:(classe*image)
b2(:,j) = 2*(pt(:,j)- a)/(b-a)-1;
end
for j=1:(classe*image)
basetest(:,j) = 2*(MatTest(:,j)- a)/(b-a)-1;
end
%%%%%%%%%%%%% network targets %%%%%%%%%%%%
k=1;
for i=1:classe
for j=1:classe*image
T(i,j)= -1;
end
end
for i=1:classe
for j=k:k+image-1
T(i,j)=1;
end
k=k+image;
end
P=b2;
clear net
[ net ] = createlstmcat( P, T);
miniBatchSize = 27;
prediction = classify(net,basetest, ...
'MiniBatchSize',miniBatchSize, ...
'SequenceLength','longest');
% neural network predictions
predclasses = vec2ind(prediction);
%confusion matrix
cmat = confusionmat(class,predclasses);
[mm,nn] = size(cmat);
cmat_diag = cmat.*eye(mm,nn);
trues = sum(sum(cmat_diag));
accuracy_nn = (trues/sum(sum(cmat))) * 100;
disp('******** Accuracy rate (%) - ARTIFICIAL NEURAL NETWORK *******');
%disp(accuracy_nn);
x=[x accuracy_nn];
TID_Performance=max(x);
disp(TID_Performance)

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by