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