How to set patternnet to get the posterior probabilty sum to unity?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposta accettata
Greg Heath
il 20 Ago 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)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!