How to set patternnet to get the posterior probabilty sum to unity?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Greg Heath
2014-8-20
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!