Daniel@0: function [h, hdata] = hbayes(net, hdata) Daniel@0: %HBAYES Evaluate Hessian of Bayesian error function for network. Daniel@0: % Daniel@0: % Description Daniel@0: % H = HBAYES(NET, HDATA) takes a network data structure NET together Daniel@0: % the data contribution to the Hessian for a set of inputs and targets. Daniel@0: % It returns the regularised Hessian using any zero mean Gaussian Daniel@0: % priors on the weights defined in NET. In addition, if a MASK is Daniel@0: % defined in NET, then the entries in H that correspond to weights with Daniel@0: % a 0 in the mask are removed. Daniel@0: % Daniel@0: % [H, HDATA] = HBAYES(NET, HDATA) additionally returns the data Daniel@0: % component of the Hessian. Daniel@0: % Daniel@0: % See also Daniel@0: % GBAYES, GLMHESS, MLPHESS, RBFHESS Daniel@0: % Daniel@0: Daniel@0: % Copyright (c) Ian T Nabney (1996-2001) Daniel@0: Daniel@0: if (isfield(net, 'mask')) Daniel@0: % Extract relevant entries in Hessian Daniel@0: nmask_rows = size(find(net.mask), 1); Daniel@0: hdata = reshape(hdata(logical(net.mask*(net.mask'))), ... Daniel@0: nmask_rows, nmask_rows); Daniel@0: nwts = nmask_rows; Daniel@0: else Daniel@0: nwts = net.nwts; Daniel@0: end Daniel@0: if isfield(net, 'beta') Daniel@0: h = net.beta*hdata; Daniel@0: else Daniel@0: h = hdata; Daniel@0: end Daniel@0: Daniel@0: if isfield(net, 'alpha') Daniel@0: if size(net.alpha) == [1 1] Daniel@0: h = h + net.alpha*eye(nwts); Daniel@0: else Daniel@0: if isfield(net, 'mask') Daniel@0: nindx_cols = size(net.index, 2); Daniel@0: index = reshape(net.index(logical(repmat(net.mask, ... Daniel@0: 1, nindx_cols))), nmask_rows, nindx_cols); Daniel@0: else Daniel@0: index = net.index; Daniel@0: end Daniel@0: h = h + diag(index*net.alpha); Daniel@0: end Daniel@0: end