how to display (show) the similarty of test image in neural network
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
primrose khaleed
il 21 Giu 2014
Commentato: primrose khaleed
il 23 Giu 2014
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 Commenti
Image Analyst
il 21 Giu 2014
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.
Risposta accettata
Greg Heath
il 23 Giu 2014
I cannot find a MATLAB code for a nearest-neighbor classifier. It looks like you'll have to code your own.
Looking at the source code of NEWPNN might help.
Greg
2 Commenti
Greg Heath
il 23 Giu 2014
This may help
>> lookfor knn
knnsearch - Find K nearest neighbors.
ClassificationKNN - K Nearest Neighbors classification
fitcknn - fit KNN classification model
templateKNN - Create a classification KNN template.
Più risposte (1)
Greg Heath
il 23 Giu 2014
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
0 Commenti
Vedere anche
Categorie
Scopri di più su Pattern Recognition and Classification in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!