Binary Classification with patternnet - wrong output

조회 수: 5 (최근 30일)
Vincent Kelber
Vincent Kelber 2020년 9월 25일
편집: Vincent Kelber 2020년 9월 29일
Hi together,
what i want to do, is to train a neural network (patternnet) classificator. Inputs are the size 10000x7, so 10.000 samples and 7 inputs.
Output is logical (10.000x1).
My problem is, if i use the patternnet function with a HiddenLayerSize > [], my output is no longer binary, than in a range between [0,1].
Here is my code:
hiddenLayerSize = [10,10,10];
net = patternnet(hiddenLayerSize, method);
net = configure(net, in_train', out_train');
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.output.processFcns = {'removeconstantrows','mapminmax'};
net.trainParam.goal = gl;
net.divideFcn = divider; % Divide data randomly
net.divideMode = divMod; % Divide up every sample
net.divideParam.trainRatio = x/100;
net.divideParam.valRatio = y/100;
net.divideParam.testRatio = z/100;
net.performFcn = pfFcn;
net.trainParam.epochs = epoch;
net.Layers{:}.transferFcn = transfer;
net = train(net,in_train',out_train'
What can i do?
Thanks :)

답변 (1개)

Anshika Chaurasia
Anshika Chaurasia 2020년 9월 28일
Hello Vincent,
It is my understanding that after training the neural network, the ouput is in range between [0,1] and you want output as logical i.e., {0,1}.
For getting logical output you could apply threshold i.e., if output >= 0.5 then output = 1 or else output = 0.
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
logical_output = zeros(1,10000);
logical_output(outputs >= 0.5) = 1; % applying threshold
  댓글 수: 1
Vincent Kelber
Vincent Kelber 2020년 9월 29일
편집: Vincent Kelber 2020년 9월 29일
Hi Anshika,
yes you are absolutely right. And that is one oportunity, yes. But the goal i want to achieve (to simplify the model) is not covered with that. Is there no other possibility to do that inside the model?
Thanks, Vinc

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by