how to interpret from output matrix of neural network that what is result

3 visualizzazioni (ultimi 30 giorni)
Hi i had to classify images as normal and pathological, in order to do that i use neural network.
to put images data into neural network i extracted features from images and converted them into column vector using (:)
D = 'Data';
Train_Feature=[];
Train_Label=[];
S = dir(fullfile(D,'*'));
N = setdiff({S([S.isdir]).name},{'.','..'}); % list of subfolders of D.
for ii = 1:numel(N)
T = dir(fullfile(D,N{ii},'*')); % improve by specifying the file extension.
C = {T(~[T.isdir]).name}; % files in subfolder.
for jj = 1:numel(C)
F = fullfile(D,N{ii},C{jj})
I=imread(F);
a=imresize(I,[256 256]);
G=rgb2gray(a);
F=extractHOGFeatures(G);
[b,c]=size(F);
X=zeros(b,c);
Y=zeros(b,c);
X(1,:)=1;
Y(1,:)=0;
Train_Feature=[Train_Feature,F(:)];
if(N{ii}=='1')
Train_Label=[Train_Label,X(:)];
else
Train_Label=[Train_Label,Y(:)];
end
end
end
save('Train_Feature','Train_Feature')
save('Train_Label','Train_Label')
and made two variables Train_Feature(input data) and Train_Label(target data).
the values that are stored in these variables are
for Train_Feature
and for Train_Label
So i put these variables(Train_Feature and Train_Label) as input data and target data to train neural network...
this is code for neural network...
inputs = Train_Feature;
targets = Train_Label;
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);
% Set up Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs)
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
% View the Network
view(net)
save('Mynetwork','net')
so in order to classify image i wrote this code
load Mynetwork
[fname, path]=uigetfile('.png','Open an Image as input for training');
fname=strcat(path, fname);
I=imread(fname);
a=imresize(I,[256 256]);
G=rgb2gray(a);
F=extractHOGFeatures(G);
answer=net(F(:))
here the answer that i get is in column matrix form...
so how do i know what was the output (that is how to know that the image belonged to which class) ???

Risposte (0)

Categorie

Scopri di più su Get Started with Deep Learning Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by