annotate toolboxes/FullBNT-1.0.7/netlab3.3/gpinit.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function net = gpinit(net, tr_in, tr_targets, prior)
Daniel@0 2 %GPINIT Initialise Gaussian Process model.
Daniel@0 3 %
Daniel@0 4 % Description
Daniel@0 5 % NET = GPINIT(NET, TRIN, TRTARGETS) takes a Gaussian Process data
Daniel@0 6 % structure NET together with a matrix TRIN of training input vectors
Daniel@0 7 % and a matrix TRTARGETS of training target vectors, and stores them
Daniel@0 8 % in NET. These datasets are required if the corresponding inverse
Daniel@0 9 % covariance matrix is not supplied to GPFWD. This is important if the
Daniel@0 10 % data structure is saved and then reloaded before calling GPFWD. Each
Daniel@0 11 % row of TRIN corresponds to one input vector and each row of TRTARGETS
Daniel@0 12 % corresponds to one target vector.
Daniel@0 13 %
Daniel@0 14 % NET = GPINIT(NET, TRIN, TRTARGETS, PRIOR) additionally initialises
Daniel@0 15 % the parameters in NET from the PRIOR data structure which contains
Daniel@0 16 % the mean and variance of the Gaussian distribution which is sampled
Daniel@0 17 % from.
Daniel@0 18 %
Daniel@0 19 % See also
Daniel@0 20 % GP, GPFWD
Daniel@0 21 %
Daniel@0 22
Daniel@0 23 % Copyright (c) Ian T Nabney (1996-2001)
Daniel@0 24
Daniel@0 25 errstring = consist(net, 'gp', tr_in, tr_targets);
Daniel@0 26 if ~isempty(errstring);
Daniel@0 27 error(errstring);
Daniel@0 28 end
Daniel@0 29
Daniel@0 30 if nargin >= 4
Daniel@0 31 % Initialise weights at random
Daniel@0 32 if size(prior.pr_mean) == [1 1]
Daniel@0 33 w = randn(1, net.nwts).*sqrt(prior.pr_var) + ...
Daniel@0 34 repmat(prior.pr_mean, 1, net.nwts);
Daniel@0 35 else
Daniel@0 36 sig = sqrt(prior.index*prior.pr_var);
Daniel@0 37 w = sig'.*randn(1, net.nwts) + (prior.index*prior.pr_mean)';
Daniel@0 38 end
Daniel@0 39 net = gpunpak(net, w);
Daniel@0 40 end
Daniel@0 41
Daniel@0 42 net.tr_in = tr_in;
Daniel@0 43 net.tr_targets = tr_targets;