MATLAB Answers

Why my neural network pattern recognition binary output totally equal 1?

1 view (last 30 days)
Ali Zulfikaroglu
Ali Zulfikaroglu on 15 Mar 2021
Edited: Madhav Thakker on 18 Mar 2021
I am studying about mammogram image to detect tumor and classify it.
I have 100x88 input and 100x2 target .
targets are :
0 0 for normal
1 0 for benign
1 1 for malign situation.
my network codes generated by matlab is below
My question is I need [1;1] situation for output .
For that my binary ouput both of bigger than 0,5 when round it to 1.
but my binary output gives totally 1. Never bigger than 0.5 both of . so doesn't exceed 1 totally.
For example 0.7 and 0.3 or 0.65 and 0.35 or 0,92 and 0,08 ....
when I round these numbers always give 1 0 result not 1 1 result.,
it should be bigger than 0.5 both of . For example like 0.6 and 0.7...
I don't know reason why it gives totatly 1 binary outputs.
Codes are below.
veri=xlsread('data.xlsx');
input=veri(:,88);
target=veri(:,89:90);
x=input';
t=target';
% 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.
% t - target data.
% 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 = 5;
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)
inputvalue=xlsread('data2.xlsx'); % I use 1x88 input in here which I know result [1;1] ,
% % I take this input from my data which is target values equal 1 1 .
a=inputvalue';
outputs = (sim(net,a))
outputss = round(sim(net,a))
% the result gives this outputs
outputs =
8.683740016534222e-01
1.316259983465778e-01
outputss =
1
0
  6 Comments
Madhav Thakker
Madhav Thakker on 18 Mar 2021
Hi,
Can you print the output of command -
net
Also, what is the shape of individual image in your dataset? The input image data is of size 100x88 and labels are of size 100x2? It means that each image if of size 100x1 and labels of size 2x1?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!