Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/netlab3.3/hbayes.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 [h, hdata] = hbayes(net, hdata) | |
2 %HBAYES Evaluate Hessian of Bayesian error function for network. | |
3 % | |
4 % Description | |
5 % H = HBAYES(NET, HDATA) takes a network data structure NET together | |
6 % the data contribution to the Hessian for a set of inputs and targets. | |
7 % It returns the regularised Hessian using any zero mean Gaussian | |
8 % priors on the weights defined in NET. In addition, if a MASK is | |
9 % defined in NET, then the entries in H that correspond to weights with | |
10 % a 0 in the mask are removed. | |
11 % | |
12 % [H, HDATA] = HBAYES(NET, HDATA) additionally returns the data | |
13 % component of the Hessian. | |
14 % | |
15 % See also | |
16 % GBAYES, GLMHESS, MLPHESS, RBFHESS | |
17 % | |
18 | |
19 % Copyright (c) Ian T Nabney (1996-2001) | |
20 | |
21 if (isfield(net, 'mask')) | |
22 % Extract relevant entries in Hessian | |
23 nmask_rows = size(find(net.mask), 1); | |
24 hdata = reshape(hdata(logical(net.mask*(net.mask'))), ... | |
25 nmask_rows, nmask_rows); | |
26 nwts = nmask_rows; | |
27 else | |
28 nwts = net.nwts; | |
29 end | |
30 if isfield(net, 'beta') | |
31 h = net.beta*hdata; | |
32 else | |
33 h = hdata; | |
34 end | |
35 | |
36 if isfield(net, 'alpha') | |
37 if size(net.alpha) == [1 1] | |
38 h = h + net.alpha*eye(nwts); | |
39 else | |
40 if isfield(net, 'mask') | |
41 nindx_cols = size(net.index, 2); | |
42 index = reshape(net.index(logical(repmat(net.mask, ... | |
43 1, nindx_cols))), nmask_rows, nindx_cols); | |
44 else | |
45 index = net.index; | |
46 end | |
47 h = h + diag(index*net.alpha); | |
48 end | |
49 end |