def __init__(self, likelihood_or_Y_list, input_dim, num_inducing=10, names=None, kernels=None, initx='PCA', initz='permute', _debug=False, **kw): if names is None: self.names = [ "{}".format(i + 1) for i in range(len(likelihood_or_Y_list)) ] # sort out the kernels if kernels is None: kernels = [None] * len(likelihood_or_Y_list) elif isinstance(kernels, kern): kernels = [ kernels.copy() for i in range(len(likelihood_or_Y_list)) ] else: assert len(kernels) == len( likelihood_or_Y_list), "need one kernel per output" assert all([isinstance(k, kern) for k in kernels]), "invalid kernel object detected!" assert not ('kernel' in kw), "pass kernels through `kernels` argument" self.input_dim = input_dim self.num_inducing = num_inducing self._debug = _debug self._init = True X = self._init_X(initx, likelihood_or_Y_list) Z = self._init_Z(initz, X) self.bgplvms = [ BayesianGPLVM(l, input_dim=input_dim, kernel=k, X=X, Z=Z, num_inducing=self.num_inducing, **kw) for l, k in zip(likelihood_or_Y_list, kernels) ] del self._init self.gref = self.bgplvms[0] nparams = numpy.array( [0] + [SparseGP._get_params(g).size - g.Z.size for g in self.bgplvms]) self.nparams = nparams.cumsum() self.num_data = self.gref.num_data self.NQ = self.num_data * self.input_dim self.MQ = self.num_inducing * self.input_dim Model.__init__(self) self.ensure_default_constraints()
def _get_params(self): """ return parameter list containing private and shared parameters as follows: ================================================================= | mu | S | Z || theta1 | theta2 | .. | thetaN | ================================================================= """ X = self.gref.X.ravel() X_var = self.gref.X_variance.ravel() Z = self.gref.Z.ravel() thetas = [SparseGP._get_params(g)[g.Z.size:] for g in self.bgplvms] params = numpy.hstack([X, X_var, Z, numpy.hstack(thetas)]) return params
def __init__(self, likelihood_or_Y_list, input_dim, num_inducing=10, names=None, kernels=None, initx='PCA', initz='permute', _debug=False, **kw): if names is None: self.names = ["{}".format(i) for i in range(len(likelihood_or_Y_list))] else: self.names = names assert len(names) == len(likelihood_or_Y_list), "one name per data set required" # sort out the kernels if kernels is None: kernels = [None] * len(likelihood_or_Y_list) elif isinstance(kernels, kern): kernels = [kernels.copy() for i in range(len(likelihood_or_Y_list))] else: assert len(kernels) == len(likelihood_or_Y_list), "need one kernel per output" assert all([isinstance(k, kern) for k in kernels]), "invalid kernel object detected!" assert not ('kernel' in kw), "pass kernels through `kernels` argument" self.input_dim = input_dim self._debug = _debug self.num_inducing = num_inducing self._init = True X = self._init_X(initx, likelihood_or_Y_list) Z = self._init_Z(initz, X) self.num_inducing = Z.shape[0] # ensure M==N if M>N self.bgplvms = [BayesianGPLVM(l, input_dim=input_dim, kernel=k, X=X, Z=Z, num_inducing=self.num_inducing, **kw) for l, k in zip(likelihood_or_Y_list, kernels)] del self._init self.gref = self.bgplvms[0] nparams = numpy.array([0] + [SparseGP._get_params(g).size - g.Z.size for g in self.bgplvms]) self.nparams = nparams.cumsum() self.num_data = self.gref.num_data self.NQ = self.num_data * self.input_dim self.MQ = self.num_inducing * self.input_dim Model.__init__(self) self.ensure_default_constraints()