comparison toolboxes/FullBNT-1.0.7/netlab3.3/errbayes.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] = errbayes(net, edata)
2 %ERRBAYES Evaluate Bayesian error function for network.
3 %
4 % Description
5 % E = ERRBAYES(NET, EDATA) takes a network data structure NET together
6 % the data contribution to the error for a set of inputs and targets.
7 % It returns the regularised error using any zero mean Gaussian priors
8 % on the weights defined in NET.
9 %
10 % [E, EDATA, EPRIOR] = ERRBAYES(NET, X, T) additionally returns the
11 % data and prior components of the error.
12 %
13 % See also
14 % GLMERR, MLPERR, RBFERR
15 %
16
17 % Copyright (c) Ian T Nabney (1996-2001)
18
19 % Evaluate the data contribution to the error.
20 if isfield(net, 'beta')
21 e1 = net.beta*edata;
22 else
23 e1 = edata;
24 end
25
26 % Evaluate the prior contribution to the error.
27 if isfield(net, 'alpha')
28 w = netpak(net);
29 if size(net.alpha) == [1 1]
30 eprior = 0.5*(w*w');
31 e2 = eprior*net.alpha;
32 else
33 if (isfield(net, 'mask'))
34 nindx_cols = size(net.index, 2);
35 nmask_rows = size(find(net.mask), 1);
36 index = reshape(net.index(logical(repmat(net.mask, ...
37 1, nindx_cols))), nmask_rows, nindx_cols);
38 else
39 index = net.index;
40 end
41 eprior = 0.5*(w.^2)*index;
42 e2 = eprior*net.alpha;
43 end
44 else
45 eprior = 0;
46 e2 = 0;
47 end
48
49 e = e1 + e2;