wolffd@0: function net = gpinit(net, tr_in, tr_targets, prior) wolffd@0: %GPINIT Initialise Gaussian Process model. wolffd@0: % wolffd@0: % Description wolffd@0: % NET = GPINIT(NET, TRIN, TRTARGETS) takes a Gaussian Process data wolffd@0: % structure NET together with a matrix TRIN of training input vectors wolffd@0: % and a matrix TRTARGETS of training target vectors, and stores them wolffd@0: % in NET. These datasets are required if the corresponding inverse wolffd@0: % covariance matrix is not supplied to GPFWD. This is important if the wolffd@0: % data structure is saved and then reloaded before calling GPFWD. Each wolffd@0: % row of TRIN corresponds to one input vector and each row of TRTARGETS wolffd@0: % corresponds to one target vector. wolffd@0: % wolffd@0: % NET = GPINIT(NET, TRIN, TRTARGETS, PRIOR) additionally initialises wolffd@0: % the parameters in NET from the PRIOR data structure which contains wolffd@0: % the mean and variance of the Gaussian distribution which is sampled wolffd@0: % from. wolffd@0: % wolffd@0: % See also wolffd@0: % GP, GPFWD wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: errstring = consist(net, 'gp', tr_in, tr_targets); wolffd@0: if ~isempty(errstring); wolffd@0: error(errstring); wolffd@0: end wolffd@0: wolffd@0: if nargin >= 4 wolffd@0: % Initialise weights at random wolffd@0: if size(prior.pr_mean) == [1 1] wolffd@0: w = randn(1, net.nwts).*sqrt(prior.pr_var) + ... wolffd@0: repmat(prior.pr_mean, 1, net.nwts); wolffd@0: else wolffd@0: sig = sqrt(prior.index*prior.pr_var); wolffd@0: w = sig'.*randn(1, net.nwts) + (prior.index*prior.pr_mean)'; wolffd@0: end wolffd@0: net = gpunpak(net, w); wolffd@0: end wolffd@0: wolffd@0: net.tr_in = tr_in; wolffd@0: net.tr_targets = tr_targets;