Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/netlab3.3/rbfprior.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 [mask, prior] = rbfprior(rbfunc, nin, nhidden, nout, aw2, ab2) | |
2 %RBFPRIOR Create Gaussian prior and output layer mask for RBF. | |
3 % | |
4 % Description | |
5 % [MASK, PRIOR] = RBFPRIOR(RBFUNC, NIN, NHIDDEN, NOUT, AW2, AB2) | |
6 % generates a vector MASK that selects only the output layer weights. | |
7 % This is because most uses of RBF networks in a Bayesian context have | |
8 % fixed basis functions with the output layer as the only adjustable | |
9 % parameters. In particular, the Neuroscale output error function is | |
10 % designed to work only with this mask. | |
11 % | |
12 % The return value PRIOR is a data structure, with fields PRIOR.ALPHA | |
13 % and PRIOR.INDEX, which specifies a Gaussian prior distribution for | |
14 % the network weights in an RBF network. The parameters AW2 and AB2 are | |
15 % all scalars and represent the regularization coefficients for two | |
16 % groups of parameters in the network corresponding to second-layer | |
17 % weights, and second-layer biases respectively. Then PRIOR.ALPHA | |
18 % represents a column vector of length 2 containing the parameters, and | |
19 % PRIOR.INDEX is a matrix specifying which weights belong in each | |
20 % group. Each column has one element for each weight in the matrix, | |
21 % using the standard ordering as defined in RBFPAK, and each element is | |
22 % 1 or 0 according to whether the weight is a member of the | |
23 % corresponding group or not. | |
24 % | |
25 % See also | |
26 % RBF, RBFERR, RBFGRAD, EVIDENCE | |
27 % | |
28 | |
29 % Copyright (c) Ian T Nabney (1996-2001) | |
30 | |
31 nwts_layer2 = nout + (nhidden *nout); | |
32 switch rbfunc | |
33 case 'gaussian' | |
34 nwts_layer1 = nin*nhidden + nhidden; | |
35 case {'tps', 'r4logr'} | |
36 nwts_layer1 = nin*nhidden; | |
37 otherwise | |
38 error('Undefined activation function'); | |
39 end | |
40 nwts = nwts_layer1 + nwts_layer2; | |
41 | |
42 % Make a mask only for output layer | |
43 mask = [zeros(nwts_layer1, 1); ones(nwts_layer2, 1)]; | |
44 | |
45 if nargout > 1 | |
46 % Construct prior | |
47 indx = zeros(nwts, 2); | |
48 mark2 = nwts_layer1 + (nhidden * nout); | |
49 indx(nwts_layer1 + 1:mark2, 1) = ones(nhidden * nout, 1); | |
50 indx(mark2 + 1:nwts, 2) = ones(nout, 1); | |
51 | |
52 prior.index = indx; | |
53 prior.alpha = [aw2, ab2]'; | |
54 end |