wolffd@0: function [mask, prior] = rbfprior(rbfunc, nin, nhidden, nout, aw2, ab2) wolffd@0: %RBFPRIOR Create Gaussian prior and output layer mask for RBF. wolffd@0: % wolffd@0: % Description wolffd@0: % [MASK, PRIOR] = RBFPRIOR(RBFUNC, NIN, NHIDDEN, NOUT, AW2, AB2) wolffd@0: % generates a vector MASK that selects only the output layer weights. wolffd@0: % This is because most uses of RBF networks in a Bayesian context have wolffd@0: % fixed basis functions with the output layer as the only adjustable wolffd@0: % parameters. In particular, the Neuroscale output error function is wolffd@0: % designed to work only with this mask. wolffd@0: % wolffd@0: % The return value PRIOR is a data structure, with fields PRIOR.ALPHA wolffd@0: % and PRIOR.INDEX, which specifies a Gaussian prior distribution for wolffd@0: % the network weights in an RBF network. The parameters AW2 and AB2 are wolffd@0: % all scalars and represent the regularization coefficients for two wolffd@0: % groups of parameters in the network corresponding to second-layer wolffd@0: % weights, and second-layer biases respectively. Then PRIOR.ALPHA wolffd@0: % represents a column vector of length 2 containing the parameters, and wolffd@0: % PRIOR.INDEX is a matrix specifying which weights belong in each wolffd@0: % group. Each column has one element for each weight in the matrix, wolffd@0: % using the standard ordering as defined in RBFPAK, and each element is wolffd@0: % 1 or 0 according to whether the weight is a member of the wolffd@0: % corresponding group or not. wolffd@0: % wolffd@0: % See also wolffd@0: % RBF, RBFERR, RBFGRAD, EVIDENCE wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: nwts_layer2 = nout + (nhidden *nout); wolffd@0: switch rbfunc wolffd@0: case 'gaussian' wolffd@0: nwts_layer1 = nin*nhidden + nhidden; wolffd@0: case {'tps', 'r4logr'} wolffd@0: nwts_layer1 = nin*nhidden; wolffd@0: otherwise wolffd@0: error('Undefined activation function'); wolffd@0: end wolffd@0: nwts = nwts_layer1 + nwts_layer2; wolffd@0: wolffd@0: % Make a mask only for output layer wolffd@0: mask = [zeros(nwts_layer1, 1); ones(nwts_layer2, 1)]; wolffd@0: wolffd@0: if nargout > 1 wolffd@0: % Construct prior wolffd@0: indx = zeros(nwts, 2); wolffd@0: mark2 = nwts_layer1 + (nhidden * nout); wolffd@0: indx(nwts_layer1 + 1:mark2, 1) = ones(nhidden * nout, 1); wolffd@0: indx(mark2 + 1:nwts, 2) = ones(nout, 1); wolffd@0: wolffd@0: prior.index = indx; wolffd@0: prior.alpha = [aw2, ab2]'; wolffd@0: end