hi every body…. i used neural network…i want when enter the test image the neural network display the most similarty image of test image…how can do that?? plz help me??
the code which used is :
function taning2 load dataset2; mynet = newff(P,T,50);mynet.trainParam.epochs = 3000;mynet.trainParam.goal =1e-6; mynet.trainParam.lr = 0.01; mynet.divideFcn = 'dividerand'; % Divide data randomly
mynet.divideMode = 'sample'; % Divide up every sample
mynet.divideParam.trainRatio = 70/100; mynet.divideParam.valRatio = 15/100; mynet.divideParam.testRatio = 15/100; mynet.trainParam.show = 100; mynet.trainparam.mc = 0.95; mynet.trainParam.max_fail = 30; mynet.trainFcn = 'trainscg'; mynet.plotFcns = {'plotperform','plottrainstate','ploterrhist', ... 'plotregression', 'plotfit'};% Train the Network
[mynet,tr] = train(mynet,P,T);% Test the Network
outputs = mynet(P);errors = gsubtract(T,outputs);performance = perform(mynet,T,outputs); trainTargets = T.* tr.trainMask{1}; valTargets = T .* tr.valMask{1}; testTargets = T .* tr.testMask{1}; trainPerformance = perform(mynet,trainTargets,outputs); valPerformance = perform(mynet,valTargets,outputs); testPerformance = perform(mynet,testTargets,outputs); save mynetand the files which used to testenter image is : function testing2load mynet;load dataset2;image_dims = [46, 64];images2 = [];num_images1=1;m=imread('E:\matlab\project\neuralnetwork\a\img1.jpg');if num_images1==1 images2 = zeros(prod(image_dims), num_images1);endimg2=imresize(m,[46, 64]); images2(:,1) = img2(:);% mean_face = mean(images, 2);
mean_face4 = mean(images2, 1); shifted_images2 = images2 - repmat(mean_face4, 1, num_images1 ); [evectors1,score1, evalues1] = pcacov(images2'); num_eigenface1=16;% % % % % % % evectors3=evectors1;
evectors3 = evectors1(:, 1:num_eigenface1); score3(1,1)=score1(1,1); evalues3=evalues1'; evalues4(1,1)= evalues3(1,1); features2 = evectors3' * shifted_images2; features4=features2' ; [features3,PS2] = mapminmax(features4); features3=features3'; input=[features3;score3;evalues4]; [input,PS2] = mapminmax(input'); input=input';%tt=[1 0;0 1];
% out=mynet11(input);
% figure,plotconfusion(T,out);
simpleclassOutputs2 = sim(mynet,input); class = vec2ind(simpleclassOutputs2); disp( class );simpleclassOutputs2 = sim(mynet,input); figure,plotconfusion(simpleclassOutputs2,T);
Best Answer