comparison toolboxes/FullBNT-1.0.7/netlab3.3/glmerr.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [e, edata, eprior, y, a] = glmerr(net, x, t)
2 %GLMERR Evaluate error function for generalized linear model.
3 %
4 % Description
5 % E = GLMERR(NET, X, T) takes a generalized linear model data
6 % structure NET together with a matrix X of input vectors and a matrix
7 % T of target vectors, and evaluates the error function E. The choice
8 % of error function corresponds to the output unit activation function.
9 % Each row of X corresponds to one input vector and each row of T
10 % corresponds to one target vector.
11 %
12 % [E, EDATA, EPRIOR, Y, A] = GLMERR(NET, X, T) also returns the data
13 % and prior components of the total error.
14 %
15 % [E, EDATA, EPRIOR, Y, A] = GLMERR(NET, X) also returns a matrix Y
16 % giving the outputs of the models and a matrix A giving the summed
17 % inputs to each output unit, where each row corresponds to one
18 % pattern.
19 %
20 % See also
21 % GLM, GLMPAK, GLMUNPAK, GLMFWD, GLMGRAD, GLMTRAIN
22 %
23
24 % Copyright (c) Ian T Nabney (1996-2001)
25
26 % Check arguments for consistency
27 errstring = consist(net, 'glm', x, t);
28 if ~isempty(errstring);
29 error(errstring);
30 end
31
32 [y, a] = glmfwd(net, x);
33
34 switch net.outfn
35
36 case 'linear' % Linear outputs
37 edata = 0.5*sum(sum((y - t).^2));
38
39 case 'logistic' % Logistic outputs
40 edata = - sum(sum(t.*log(y) + (1 - t).*log(1 - y)));
41
42 case 'softmax' % Softmax outputs
43 edata = - sum(sum(t.*log(y)));
44
45 otherwise
46 error(['Unknown activation function ', net.outfn]);
47 end
48
49 [e, edata, eprior] = errbayes(net, edata);