Effacer les filtres
Effacer les filtres

When I add new image , I want to get "the result" of image in neural network pattern recognition. How can I do this according to codes added?

2 vues (au cours des 30 derniers jours)
I am studying about mammogram images to detect cancer on breast image. There are three situations benign, malign and normal.
I trained my neural netwok with 100 images and get result 95% . I will create user interface and will select an image and get the result of what is this image benign or malign or normal .
I mean my training is done and I want to see my neural network ability to detect result. I will upload a new image in user interface and want to see result of image benign or malign or normal . But I don't know which codes can I add in neural network?
Here is code neural pattern recognition created by matlab ownself. Which code should be added to detect new image (for example for 101 th image) ?
% Solve a Pattern Recognition Problem with a Neural Network
% Script generated by Neural Pattern Recognition app
% Created 07-Feb-2021 15:50:44
%
% This script assumes these variables are defined:
%
% x - input data.
% y - target data.
x = x;
t = y;
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation.
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize, trainFcn);
% Setup 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,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotconfusion(t,y)
%figure, plotroc(t,y)

Réponses (1)

Abhishek Gupta
Abhishek Gupta le 17 Fév 2021
Modifié(e) : Abhishek Gupta le 17 Fév 2021
Hi,
As per my understanding, you want to make predictions for new input using your trained network. You can do the same using the 'predict()' function in MATLAB: -
predictions = predict(trainedNetwork,newImages);
For more information, check out the documentation here: -
  4 commentaires
Ali Zulfikaroglu
Ali Zulfikaroglu le 20 Fév 2021
I used glcm feature extraction methods to detect properties of image and glcm gives 88 properties (such as homogenity, entropy, energy...). I wrote 88 numbers in excel file and these are my input and I write output according to this 88 properties . I have data in excel file . In excel file , there is 88x100 input and 2x100 target. The code above x= input and y= my target data. I trained my network with this inputs and targets . You can see code above. And then I added new image and get glcm properties of it again 88 features . And I wonder its output "what" according to this 88 features .
predictions = predict(net,a);
net is my trained network and a is that new image's 88 properties.
and this code doen't work.
But I used new_outputs=sim(net,a) it worked.
Should we use "sim" command or "predict" command ? "sim" command is true in here?
Abhishek Gupta
Abhishek Gupta le 22 Fév 2021
What error are you getting while using "predict()"? What is the dimension of 'a'? Note that "a" should be an N-by-numFeatures numeric array, where N is the number of observations and numFeatures is the number of features of the input data. I see N=1 in your case, so "a" should be of (1x88) dimension.
For more information, check out the "Input Arguments" section of the documentation: -

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by