how to display (show) the similarty of test image in neural network
이전 댓글 표시
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 mynet
and the files which used to testenter image is :
function testing2
load 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);
end
img2=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);
댓글 수: 5
Image Analyst
2014년 6월 21일
When you say you want to "display the most similarty image" , does that mean you want to know how to display an image or how to create the neural network to determine similarity?
Image Analyst
2014년 6월 21일
Your edit did not work - formatting is still very messed up. Try reading this and trying to format your code again: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
primrose khaleed
2014년 6월 21일
Image Analyst
2014년 6월 21일
I can answer the display part. Use imshow(). For the NN part, you'll have to wait for Greg Heath. In the meantime, review his answers here to other people.
primrose khaleed
2014년 6월 22일
채택된 답변
추가 답변 (1개)
Greg Heath
2014년 6월 23일
1 개 추천
The answer to your question is: If you classify an input using a MLP like patternnet, you have to compare the input with every training vector of that class in order to determine the most similar.
Q: Does that make sense?
A: No
Q: Why not?
A: There are other classifiers that assign classes using a measure similarity. Search
nearest neighbor
Hope this helps
카테고리
도움말 센터 및 File Exchange에서 Nearest Neighbors에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!