How to set patternnet to get the posterior probabilty sum to unity?

2 Ansichten (letzte 30 Tage)
I've a 2-class problem and I want the posterior probability of output to sum to 1. Hence, I'm using 'softmax' transfer function for the output layer. Here's my code.
net = patternnet(10);
net.divideParam.trainRatio = 80/100;
net.divideParam.valRatio = 20/100;
net.layers{2}.transferFcn = 'softmax';
[net, tr] = train(net, trainInputs, trainTargets);
testOutputs = net(testInputs);
disp(testOutputs')
The sum of the output values exceed 1 though. I must be missing something. Please help. Thanks.

Akzeptierte Antwort

Greg Heath
Greg Heath am 20 Aug. 2014
help nndataset % Choose classification/pattern-recognition data with 2 classes
close all, clear all, clc
for k=1:4
if k==1
[x,t] = crab_dataset;
elseif k==2
[x,t] = glass_dataset;
elseif k==3
[x,t] = cancer_dataset;
elseif k==4
[x,t] = ovarian_dataset;
end
[ I N ] = size(x)
[ O N ] = size(t)
check1(k) = max(abs(sum(t)-ones(1,N)))
net = patternnet(10);
[ net tr y ] = train(net,x,t);
check2(k) = max(abs(sum(y)-ones(1,N)))
end
%check1 = 0 0 0 0
%check2 = 2.2204e-16 * ones(1,4)

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by