comparison toolboxes/FullBNT-1.0.7/netlab3.3/gpinit.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 = gpinit(net, tr_in, tr_targets, prior)
2 %GPINIT Initialise Gaussian Process model.
3 %
4 % Description
5 % NET = GPINIT(NET, TRIN, TRTARGETS) takes a Gaussian Process data
6 % structure NET together with a matrix TRIN of training input vectors
7 % and a matrix TRTARGETS of training target vectors, and stores them
8 % in NET. These datasets are required if the corresponding inverse
9 % covariance matrix is not supplied to GPFWD. This is important if the
10 % data structure is saved and then reloaded before calling GPFWD. Each
11 % row of TRIN corresponds to one input vector and each row of TRTARGETS
12 % corresponds to one target vector.
13 %
14 % NET = GPINIT(NET, TRIN, TRTARGETS, PRIOR) additionally initialises
15 % the parameters in NET from the PRIOR data structure which contains
16 % the mean and variance of the Gaussian distribution which is sampled
17 % from.
18 %
19 % See also
20 % GP, GPFWD
21 %
22
23 % Copyright (c) Ian T Nabney (1996-2001)
24
25 errstring = consist(net, 'gp', tr_in, tr_targets);
26 if ~isempty(errstring);
27 error(errstring);
28 end
29
30 if nargin >= 4
31 % Initialise weights at random
32 if size(prior.pr_mean) == [1 1]
33 w = randn(1, net.nwts).*sqrt(prior.pr_var) + ...
34 repmat(prior.pr_mean, 1, net.nwts);
35 else
36 sig = sqrt(prior.index*prior.pr_var);
37 w = sig'.*randn(1, net.nwts) + (prior.index*prior.pr_mean)';
38 end
39 net = gpunpak(net, w);
40 end
41
42 net.tr_in = tr_in;
43 net.tr_targets = tr_targets;