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