Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/netlab3.3/glminit.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 net = glminit(net, prior) | |
2 %GLMINIT Initialise the weights in a generalized linear model. | |
3 % | |
4 % Description | |
5 % | |
6 % NET = GLMINIT(NET, PRIOR) takes a generalized linear model NET and | |
7 % sets the weights and biases by sampling from a Gaussian distribution. | |
8 % If PRIOR is a scalar, then all of the parameters (weights and biases) | |
9 % are sampled from a single isotropic Gaussian with inverse variance | |
10 % equal to PRIOR. If PRIOR is a data structure similar to that in | |
11 % MLPPRIOR but for a single layer of weights, then the parameters are | |
12 % sampled from multiple Gaussians according to their groupings (defined | |
13 % by the INDEX field) with corresponding variances (defined by the | |
14 % ALPHA field). | |
15 % | |
16 % See also | |
17 % GLM, GLMPAK, GLMUNPAK, MLPINIT, MLPPRIOR | |
18 % | |
19 | |
20 % Copyright (c) Ian T Nabney (1996-2001) | |
21 | |
22 errstring = consist(net, 'glm'); | |
23 if ~isempty(errstring); | |
24 error(errstring); | |
25 end | |
26 if isstruct(prior) | |
27 sig = 1./sqrt(prior.index*prior.alpha); | |
28 w = sig'.*randn(1, net.nwts); | |
29 elseif size(prior) == [1 1] | |
30 w = randn(1, net.nwts).*sqrt(1/prior); | |
31 else | |
32 error('prior must be a scalar or a structure'); | |
33 end | |
34 | |
35 net = glmunpak(net, w); | |
36 |