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

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

With neural networks, you typically need to try various "designs" to see which works best. You should try increasing the number of hidden layers / size of the hidden layers.
For example you can create 3 hidden layers with sizes 10,8,5 as follows.
hiddenLayerSize = [10,8,5];
I tried hiddenLayerSize = [10,8,5];
and output is still same
outputs =
5.822416153155460e-01
4.177583846844541e-01
I mean two ouputs totaly again 1.
my question is I don't want totaly 1 output. Why this make it 1 ?
My aim is I should get two more than 0.5 outputs.
Your dataset maynot be balanced. How many of your data is each of the three types ?
I increased inputs and tried 200.
125 : 0 0
46 : 1 0
29 : 1 1
but I don't think the reason unbalanced dataset.
because I can get [0.3; 0.7] or vice versa [0.7 0.3] outputs .
But why outputs total (0.7+0.3) is 1? I should get outputs without depend on 1 .
If you don't mind to upload your data here.
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)

Asked:

on 15 Mar 2021

Edited:

on 18 Mar 2021

Community Treasure Hunt

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

Start Hunting!