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