[x,t] = iris_dataset; net = patternnet(10); net = train(net,x,t); y = net(x); perf = crossentropy(net,t,y)
When I run this code, I get perf = 0.0367. To verify this result, I ran the code:
ce = -mean(sum(t.*log(y)+(1-t).*log(1-y)))
which resulted in ce = 0.1100. Why are perf and ce unequal? Do I have an error in my calculation?
Xent1 = -sum( t.*log(y))
For non-mutually exclusive targets and a logsig output, the corresponding form for crossentropy is
Xent2 = -sum( t.*log(y)) + (1-t).*log(1-y))
For your example I get
clear all, clc [ x, t ] = iris_dataset; [ O N ] = size(t) % [ 3 150 ] minmax0 = repmat([0 1],3,1) checkt1 = max(abs( minmax(t)- minmax0))%[0 0] checkt2 = max(abs(sum(t)-ones(1,N))) % 0 net = patternnet(10); rng(0) [ net tr y ] = train(net,x,t); checky1 = max(abs( minmax(y)- minmax0)) % checky1 = [ 2.4214e-4 1.8807e-3 ] checky2 = max(abs(sum(y)-ones(1,N))) % 2.2204e-16 perf = crossentropy(net,t,y) % 0.033005 Xent1 = mean(-sum(t.*log(y))) % 0.049552 Xent3 = mean(-sum((1-t).*log(1-y))) % 0.049464 Xent2 = mean(-sum(t.*log(y)+ (1-t).*log(1-y))) % 0.099015
Unfortunately, none of the following gives a formula
help crossentropy doc crossentropy type crossentropy
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.