How to set patternnet to get the posterior probabilty sum to unity?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
coolguynp
el 9 de En. de 2014
Respondida: Greg Heath
el 20 de Ag. de 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 comentarios
Respuesta aceptada
Greg Heath
el 20 de Ag. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!