diff options
| author | ziejd2 | 2017-09-28 15:04:40 -0500 |
|---|---|---|
| committer | ziejd2 | 2017-09-28 15:04:40 -0500 |
| commit | 8070dc963753142bb86c4ed698d91fd623ed28e7 (patch) | |
| tree | d0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/netlab3.3/gpinit.m | |
| parent | 7cc31810d53176e805532b2789955f4eedbce6bb (diff) | |
| download | BNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz | |
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/netlab3.3/gpinit.m')
| -rw-r--r-- | sourcecodes/bnt-master/netlab3.3/gpinit.m | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/netlab3.3/gpinit.m b/sourcecodes/bnt-master/netlab3.3/gpinit.m new file mode 100644 index 00000000..c355c0d5 --- /dev/null +++ b/sourcecodes/bnt-master/netlab3.3/gpinit.m @@ -0,0 +1,43 @@ +function net = gpinit(net, tr_in, tr_targets, prior) +%GPINIT Initialise Gaussian Process model. +% +% Description +% NET = GPINIT(NET, TRIN, TRTARGETS) takes a Gaussian Process data +% structure NET together with a matrix TRIN of training input vectors +% and a matrix TRTARGETS of training target vectors, and stores them +% in NET. These datasets are required if the corresponding inverse +% covariance matrix is not supplied to GPFWD. This is important if the +% data structure is saved and then reloaded before calling GPFWD. Each +% row of TRIN corresponds to one input vector and each row of TRTARGETS +% corresponds to one target vector. +% +% NET = GPINIT(NET, TRIN, TRTARGETS, PRIOR) additionally initialises +% the parameters in NET from the PRIOR data structure which contains +% the mean and variance of the Gaussian distribution which is sampled +% from. +% +% See also +% GP, GPFWD +% + +% Copyright (c) Ian T Nabney (1996-2001) + +errstring = consist(net, 'gp', tr_in, tr_targets); +if ~isempty(errstring); + error(errstring); +end + +if nargin >= 4 + % Initialise weights at random + if size(prior.pr_mean) == [1 1] + w = randn(1, net.nwts).*sqrt(prior.pr_var) + ... + repmat(prior.pr_mean, 1, net.nwts); + else + sig = sqrt(prior.index*prior.pr_var); + w = sig'.*randn(1, net.nwts) + (prior.index*prior.pr_mean)'; + end + net = gpunpak(net, w); +end + +net.tr_in = tr_in; +net.tr_targets = tr_targets; |
