Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/netlab3.3/mlphess.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] = mlphess(net, x, t, hdata) | |
2 %MLPHESS Evaluate the Hessian matrix for a multi-layer perceptron network. | |
3 % | |
4 % Description | |
5 % H = MLPHESS(NET, X, T) takes an MLP network data structure NET, a | |
6 % matrix X of input values, and a matrix T of target values and returns | |
7 % the full Hessian matrix H corresponding to the second derivatives of | |
8 % the negative log posterior distribution, evaluated for the current | |
9 % weight and bias values as defined by NET. | |
10 % | |
11 % [H, HDATA] = MLPHESS(NET, X, T) returns both the Hessian matrix H and | |
12 % the contribution HDATA arising from the data dependent term in the | |
13 % Hessian. | |
14 % | |
15 % H = MLPHESS(NET, X, T, HDATA) takes a network data structure NET, a | |
16 % matrix X of input values, and a matrix T of target values, together | |
17 % with the contribution HDATA arising from the data dependent term in | |
18 % the Hessian, and returns the full Hessian matrix H corresponding to | |
19 % the second derivatives of the negative log posterior distribution. | |
20 % This version saves computation time if HDATA has already been | |
21 % evaluated for the current weight and bias values. | |
22 % | |
23 % See also | |
24 % MLP, HESSCHEK, MLPHDOTV, EVIDENCE | |
25 % | |
26 | |
27 % Copyright (c) Ian T Nabney (1996-2001) | |
28 | |
29 % Check arguments for consistency | |
30 errstring = consist(net, 'mlp', x, t); | |
31 if ~isempty(errstring); | |
32 error(errstring); | |
33 end | |
34 | |
35 if nargin == 3 | |
36 % Data term in Hessian needs to be computed | |
37 hdata = datahess(net, x, t); | |
38 end | |
39 | |
40 [h, hdata] = hbayes(net, hdata); | |
41 | |
42 % Sub-function to compute data part of Hessian | |
43 function hdata = datahess(net, x, t) | |
44 | |
45 hdata = zeros(net.nwts, net.nwts); | |
46 | |
47 for v = eye(net.nwts); | |
48 hdata(find(v),:) = mlphdotv(net, x, t, v); | |
49 end | |
50 | |
51 return |