How to set patternnet to get the posterior probabilty sum to unity?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
coolguynp
le 9 Jan 2014
Réponse apportée : Greg Heath
le 20 Août 2014
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 commentaires
Réponse acceptée
Greg Heath
le 20 Août 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!