text
stringlengths
81
112k
Update gradient in the order in which parameters are represented in the kernel def sde_update_gradient_full(self, gradients): """ Update gradient in the order in which parameters are represented in the kernel """ part_start_param_index = 0 for p in self.parts: ...
Convert the object into a json serializable dictionary. Note: It uses the private method _save_to_input_dict of the parent. :return dict: json serializable dictionary containing the needed information to instantiate the object def to_dict(self): """ Convert the object into a json seri...
Compute the covariance matrix between X and X2. def K(self, X, X2=None): """Compute the covariance matrix between X and X2.""" if X2 is None: X2 = X base = np.pi * (X[:, None, :] - X2[None, :, :]) / self.period exp_dist = np.exp( -0.5* np.sum( np.square( np.sin( base ) / s...
Compute the diagonal of the covariance matrix associated to X. def Kdiag(self, X): """Compute the diagonal of the covariance matrix associated to X.""" ret = np.empty(X.shape[0]) ret[:] = self.variance return ret
derivative of the covariance matrix with respect to the parameters. def update_gradients_full(self, dL_dK, X, X2=None): """derivative of the covariance matrix with respect to the parameters.""" if X2 is None: X2 = X base = np.pi * (X[:, None, :] - X2[None, :, :]) / self.period ...
derivative of the diagonal of the covariance matrix with respect to the parameters. def update_gradients_diag(self, dL_dKdiag, X): """derivative of the diagonal of the covariance matrix with respect to the parameters.""" self.variance.gradient = np.sum(dL_dKdiag) self.period.gradient = 0 ...
Plot the geometry of a shapefile :param shape_records: geometry and attributes list :type shape_records: ShapeRecord object (output of a shapeRecords() method) :param facecolor: color to be used to fill in polygons :param edgecolor: color to be used for lines :param ax: axes to plot on. :type a...
Return the geometry and attributes of a shapefile whose fields match a regular expression given :param sf: shapefile :type sf: shapefile object :regex: regular expression to match :type regex: string :field: field number to be matched with the regex :type field: integer def string_match(sf,reg...
Return the geometry and attributes of a shapefile that lie within (or intersect) a bounding box :param sf: shapefile :type sf: shapefile object :param bbox: bounding box :type bbox: list of floats [x_min,y_min,x_max,y_max] :inside_only: True if the objects returned are those that lie within the bbo...
Plot the geometry of a shapefile within a bbox :param sf: shapefile :type sf: shapefile object :param bbox: bounding box :type bbox: list of floats [x_min,y_min,x_max,y_max] :inside_only: True if the objects returned are those that lie within the bbox and False if the objects returned are any that ...
Plot the geometry of a shapefile whose fields match a regular expression given :param sf: shapefile :type sf: shapefile object :regex: regular expression to match :type regex: string :field: field number to be matched with the regex :type field: integer def plot_string_match(sf,regex,field,**k...
Use bbox as xlim and ylim in ax def apply_bbox(sf,ax): """ Use bbox as xlim and ylim in ax """ limits = sf.bbox xlim = limits[0],limits[2] ylim = limits[1],limits[3] ax.set_xlim(xlim) ax.set_ylim(ylim)
Notice that we update the warping function gradients here. def parameters_changed(self): """ Notice that we update the warping function gradients here. """ self.Y_normalized[:] = self.transform_data() super(WarpedGP, self).parameters_changed() Kiy = self.posterior.woodbu...
Notice we add the jacobian of the warping function here. def log_likelihood(self): """ Notice we add the jacobian of the warping function here. """ ll = GP.log_likelihood(self) jacobian = self.warping_function.fgrad_y(self.Y_untransformed) return ll + np.log(jacobian).su...
Calculate the warped mean by using Gauss-Hermite quadrature. def _get_warped_mean(self, mean, std, pred_init=None, deg_gauss_hermite=20): """ Calculate the warped mean by using Gauss-Hermite quadrature. """ gh_samples, gh_weights = np.polynomial.hermite.hermgauss(deg_gauss_hermite) ...
Calculate the warped variance by using Gauss-Hermite quadrature. def _get_warped_variance(self, mean, std, pred_init=None, deg_gauss_hermite=20): """ Calculate the warped variance by using Gauss-Hermite quadrature. """ gh_samples, gh_weights = np.polynomial.hermite.hermgauss(deg_gauss_h...
Prediction results depend on: - The value of the self.predict_in_warped_space flag - The median flag passed as argument The likelihood keyword is never used, it is just to follow the plotting API. def predict(self, Xnew, kern=None, pred_init=None, Y_metadata=None, median=False, ...
Get the predictive quantiles around the prediction at X :param X: The points at which to make a prediction :type X: np.ndarray (Xnew x self.input_dim) :param quantiles: tuple of quantiles, default is (2.5, 97.5) which is the 95% interval :type quantiles: tuple :returns: list of ...
Calculation of the log predictive density. Notice we add the jacobian of the warping function here. .. math: p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\mu_{*}\\sigma^{2}_{*}) :param x_test: test locations (x_{*}) :type x_test: (Nx1) array :param y_test: test observations (...
Update gradient in the order in which parameters are represented in the kernel def sde_update_gradient_full(self, gradients): """ Update gradient in the order in which parameters are represented in the kernel """ self.variance.gradient = gradients[0] self.le...
Return the state space representation of the covariance. def sde(self): """ Return the state space representation of the covariance. """ variance = float(self.variance.values) lengthscale = float(self.lengthscale.values) lamda = np.sqrt(5.0)/lengthscale ...
Sample the (unfixed) model parameters. :param num_samples: the number of samples to draw (1000 by default) :type num_samples: int :param hmc_iters: the number of leap-frog iterations (20 by default) :type hmc_iters: int :return: the list of parameters samples with the si...
Method that is called upon any changes to :class:`~GPy.core.parameterization.param.Param` variables within the model. In particular in the GP class this method reperforms inference, recalculating the posterior and log marginal likelihood and gradients of the model .. warning:: This method i...
Make a prediction for the latent function values def _raw_predict(self, Xnew, full_cov=False, kern=None): """ Make a prediction for the latent function values """ if kern is None: kern = self.kern # compute mean predictions Kmn = kern.K(Xnew, self.X) ...
Return the state space representation of the covariance. def sde(self): """ Return the state space representation of the covariance. """ variance = float(self.variances.values) # this is initial variancve in Bayesian linear regression t0 = float(self.t0) ...
Compute the covariance matrix between X and X2. def K(self, X, X2=None): # model : -a d^2y/dx^2 + b dy/dt + c * y = U # kernel Kyy rbf spatiol temporal # vyt Y temporal variance vyx Y spatiol variance lyt Y temporal lengthscale lyx Y spatiol lengthscale # kernel Kuu doper( doper(Kyy)) ...
Compute the diagonal of the covariance matrix associated to X. def Kdiag(self, X): """Compute the diagonal of the covariance matrix associated to X.""" vyt = self.variance_Yt vyx = self.variance_Yx lyt = 1./(2*self.lengthscale_Yt) lyx = 1./(2*self.lengthscale_Yx) a = s...
derivative of the covariance matrix with respect to the parameters. def update_gradients_full(self, dL_dK, X, X2=None): #def dK_dtheta(self, dL_dK, X, X2, target): """derivative of the covariance matrix with respect to the parameters.""" X,slices = X[:,:-1],index_to_slices(X[:,-1]) if X2 is...
Get the gradients of the posterior distribution of X in its specific form. def get_X_gradients(self, X): """Get the gradients of the posterior distribution of X in its specific form.""" return X.mean.gradient, X.variance.gradient, X.binary_prob.gradient
Sample the loading matrix if the kernel is linear. def sample_W(self, nSamples, raw_samples=False): """ Sample the loading matrix if the kernel is linear. """ assert isinstance(self.kern, kern.Linear) from ..util.linalg import pdinv N, D = self.Y.shape Q = self.X...
Convert the object into a json serializable dictionary. Note: It uses the private method _save_to_input_dict of the parent. :return dict: json serializable dictionary containing the needed information to instantiate the object def to_dict(self): """ Convert the object into a json seri...
Convert the object into a json serializable dictionary. Note: It uses the private method _save_to_input_dict of the parent. :return dict: json serializable dictionary containing the needed information to instantiate the object def to_dict(self): """ Convert the object into a json seri...
Convert the object into a json serializable dictionary. Note: It uses the private method _save_to_input_dict of the parent. :return dict: json serializable dictionary containing the needed information to instantiate the object def to_dict(self): """ Convert the object into a json seri...
Compute the KL divergence to another NormalPosterior Object. This only holds, if the two NormalPosterior objects have the same shape, as we do computational tricks for the multivariate normal KL divergence. def KL(self, other): """Compute the KL divergence to another NormalPosterior Object. This only holds, if...
Plot latent space X in 1D: See GPy.plotting.matplot_dep.variational_plots def plot(self, *args, **kwargs): """ Plot latent space X in 1D: See GPy.plotting.matplot_dep.variational_plots """ import sys assert "matplotlib" in sys.modules, "matplotlib package has...
Generic chaining function for second derivative .. math:: \\frac{d^{2}(f . g)}{dx^{2}} = \\frac{d^{2}f}{dg^{2}}(\\frac{dg}{dx})^{2} + \\frac{df}{dg}\\frac{d^{2}g}{dx^{2}} def chain_2(d2f_dg2, dg_dx, df_dg, d2g_dx2): """ Generic chaining function for second derivative .. math:: \\frac{...
Generic chaining function for third derivative .. math:: \\frac{d^{3}(f . g)}{dx^{3}} = \\frac{d^{3}f}{dg^{3}}(\\frac{dg}{dx})^{3} + 3\\frac{d^{2}f}{dg^{2}}\\frac{dg}{dx}\\frac{d^{2}g}{dx^{2}} + \\frac{df}{dg}\\frac{d^{3}g}{dx^{3}} def chain_3(d3f_dg3, dg_dx, d2f_dg2, d2g_dx2, df_dg, d3g_dx3): """ ...
Creates a D-dimensional grid of n linearly spaced points :param D: dimension of the grid :param n: number of points :param min_max: (min, max) list def linear_grid(D, n = 100, min_max = (-100, 100)): """ Creates a D-dimensional grid of n linearly spaced points :param D: dimension of the grid ...
This is the same initialization algorithm that is used in Kmeans++. It's quite simple and very useful to initialize the locations of the inducing points in sparse GPs. :param X: data :param m: number of inducing points def kmm_init(X, m = 10): """ This is the same initialization algorithm that...
Convert an arbitrary number of parameters to :class:ndarray class objects. This is for converting parameter objects to numpy arrays, when using scipy.weave.inline routine. In scipy.weave.blitz there is no automatic array detection (even when the array inherits from :class:ndarray) def param_to_array(*para...
Compute the diagonal of the covariance matrix associated to X. def Kdiag(self, X): """Compute the diagonal of the covariance matrix associated to X.""" Kdiag = np.zeros(X.shape[0]) ly=1/self.lengthscale_Y lu=np.sqrt(3)/self.lengthscale_U Vu = self.variance_U Vy=self.var...
derivative of the covariance matrix with respect to the parameters. def update_gradients_full(self, dL_dK, X, X2=None): """derivative of the covariance matrix with respect to the parameters.""" X,slices = X[:,:-1],index_to_slices(X[:,-1]) if X2 is None: X2,slices2 = X,slices ...
Set the data without calling parameters_changed to avoid wasted computation If this is called by the stochastic_grad function this will immediately update the gradients def set_data(self, X, Y): """ Set the data without calling parameters_changed to avoid wasted computation If this is c...
Return a new batch of X and Y by taking a chunk of data from the complete X and Y def new_batch(self): """ Return a new batch of X and Y by taking a chunk of data from the complete X and Y """ i = next(self.slicer) return self.X_all[i], self.Y_all[i]
Instantiate an object of a derived class using the information in input_dict (built by the to_dict method of the derived class). More specifically, after reading the derived class from input_dict, it calls the method _build_from_input_dict of the derived class. Note: This method should n...
Convert the object into a json serializable dictionary. Note: It uses the private method _save_to_input_dict of the parent. :return dict: json serializable dictionary containing the needed information to instantiate the object def to_dict(self): """ Convert the object into a json seri...
Make a prediction for the function, to which we will pass the additional arguments def predict(self,function,args): """Make a prediction for the function, to which we will pass the additional arguments""" param = self.model.param_array fs = [] for p in self.chain: self.model...
Return shape is NxMx(Ntheta) def _param_grad_helper(self,X,X2,target): """Return shape is NxMx(Ntheta)""" if X2 is None: X2 = X FX = np.column_stack([f(X) for f in self.F]) FX2 = np.column_stack([f(X2) for f in self.F]) DER = np.zeros((self.n,self.n,self.n)) for i in ran...
Set the input / output data of the model This is useful if we wish to change our existing data but maintain the same model :param X: input observations :type X: np.ndarray :param Y: output observations :type Y: np.ndarray or ObsAr def set_XY(self, X, Y): """ Set...
Set the input data of the model :param X: input observations :type X: np.ndarray def set_X(self, X): """ Set the input data of the model :param X: input observations :type X: np.ndarray """ assert isinstance(X, np.ndarray) state = self.update_mo...
Set the output data of the model :param Y: output observations :type Y: np.ndarray or ObsArray def set_Y(self, Y): """ Set the output data of the model :param Y: output observations :type Y: np.ndarray or ObsArray """ assert isinstance(Y, (np.ndarray, O...
Method that is called upon any changes to :class:`~GPy.core.parameterization.param.Param` variables within the model. In particular in this class this method re-performs inference, recalculating the posterior, log marginal likelihood and gradients of the model .. warning:: This method is no...
For making predictions, does not account for normalization or likelihood full_cov is a boolean which defines whether the full covariance matrix of the prediction is computed. If full_cov is False (default), only the diagonal of the covariance is returned. .. math:: p(f*|X*,...
Predict the function(s) at the new point(s) Xnew. For Student-t processes, this method is equivalent to predict_noiseless as no likelihood is included in the model. def predict(self, Xnew, full_cov=False, kern=None, **kwargs): """ Predict the function(s) at the new point(s) Xnew. For Student-t ...
Predict the underlying function f at the new point(s) Xnew. :param Xnew: The points at which to make a prediction :type Xnew: np.ndarray (Nnew x self.input_dim) :param full_cov: whether to return the full covariance matrix, or just the diagonal :type full_cov: bool :param kern:...
Get the predictive quantiles around the prediction at X :param X: The points at which to make a prediction :type X: np.ndarray (Xnew x self.input_dim) :param quantiles: tuple of quantiles, default is (2.5, 97.5) which is the 95% interval :type quantiles: tuple :param kern: optio...
Samples the posterior GP at the points X, equivalent to posterior_samples_f due to the absence of a likelihood. def posterior_samples(self, X, size=10, full_cov=False, Y_metadata=None, likelihood=None, **predict_kwargs): """ Samples the posterior GP at the points X, equivalent to posterior_samples_f du...
Samples the posterior TP at the points X. :param X: The points at which to take the samples. :type X: np.ndarray (Nnew x self.input_dim) :param size: the number of a posteriori samples. :type size: int. :param full_cov: whether to return the full covariance matrix, or just the d...
Get a view on the diagonal elements of a 2D array. This is actually a view (!) on the diagonal of the array, so you can in-place adjust the view. :param :class:`ndarray` A: 2 dimensional numpy array :param int offset: view offset to give back (negative entries allowed) :rtype: :class:`ndarray` vie...
Times the view of A with b in place (!). Returns modified A Broadcasting is allowed, thus b can be scalar. if offset is not zero, make sure b is of right shape! :param ndarray A: 2 dimensional array :param ndarray-like b: either one dimensional or scalar :param int offset: same as in view. ...
Divide the view of A by b in place (!). Returns modified A Broadcasting is allowed, thus b can be scalar. if offset is not zero, make sure b is of right shape! :param ndarray A: 2 dimensional array :param ndarray-like b: either one dimensional or scalar :param int offset: same as in view. ...
Add b to the view of A in place (!). Returns modified A. Broadcasting is allowed, thus b can be scalar. if offset is not zero, make sure b is of right shape! :param ndarray A: 2 dimensional array :param ndarray-like b: either one dimensional or scalar :param int offset: same as in view. :r...
Subtract b from the view of A in place (!). Returns modified A. Broadcasting is allowed, thus b can be scalar. if offset is not zero, make sure b is of right shape! :param ndarray A: 2 dimensional array :param ndarray-like b: either one dimensional or scalar :param int offset: same as in view....
Instantiate an object of a derived class using the information in input_dict (built by the to_dict method of the derived class). More specifically, after reading the derived class from input_dict, it calls the method _build_from_input_dict of the derived class. Note: This method should n...
Convert the object into a json serializable dictionary. Note: It uses the private method _save_to_input_dict of the parent. :return dict: json serializable dictionary containing the needed information to instantiate the object def to_dict(self): """ Convert the object into a json seri...
Compute the gradient of the objective function with respect to X. :param dL_dK: An array of gradients of the objective function with respect to the covariance function. :type dL_dK: np.ndarray (num_samples x num_inducing) :param X: Observed data inputs :type X: np.ndarray (num_samples x...
Support adding kernels for sde representation def sde(self): """ Support adding kernels for sde representation """ import scipy.linalg as la F = None L = None Qc = None H = None Pinf = None P0 = None dF = No...
Returns error rate and true/false positives in a binary classification problem - Actual classes are displayed by column. - Predicted classes are displayed by row. :param p: array of class '1' probabilities. :param labels: array of actual classes. :param names: list of class names, defaults to ['1',...
Convert the object into a json serializable dictionary. :param boolean save_data: if true, it adds the training data self.X and self.Y to the dictionary :return dict: json serializable dictionary containing the needed information to instantiate the object def to_dict(self, save_data=True): """...
return a F ordered version of A, assuming A is symmetric def force_F_ordered_symmetric(A): """ return a F ordered version of A, assuming A is symmetric """ if A.flags['F_CONTIGUOUS']: return A if A.flags['C_CONTIGUOUS']: return A.T else: return np.asfortranarray(A)
Wrapper for lapack dtrtrs function DTRTRS solves a triangular system of the form A * X = B or A**T * X = B, where A is a triangular matrix of order N, and B is an N-by-NRHS matrix. A check is made to verify that A is nonsingular. :param A: Matrix A(triangular) :param B: Matrix B :...
Wrapper for lapack dpotrs function :param A: Matrix A :param B: Matrix B :param lower: is matrix lower (true) or upper (false) :returns: def dpotrs(A, B, lower=1): """ Wrapper for lapack dpotrs function :param A: Matrix A :param B: Matrix B :param lower: is matrix lower (true) or up...
Wrapper for lapack dpotri function DPOTRI - compute the inverse of a real symmetric positive definite matrix A using the Cholesky factorization A = U**T*U or A = L*L**T computed by DPOTRF :param A: Matrix A :param lower: is matrix lower (true) or upper (false) :returns: A inverse def dpot...
Determinant of a positive definite matrix, only symmetric matricies though def pddet(A): """ Determinant of a positive definite matrix, only symmetric matricies though """ L = jitchol(A) logdetA = 2*sum(np.log(np.diag(L))) return logdetA
Multiply all the arguments using matrix product rules. The output is equivalent to multiplying the arguments one by one from left to right using dot(). Precedence can be controlled by creating tuples of arguments, for instance mdot(a,((b,c),d)) multiplies a (a*((b*c)*d)). Note that this means the ou...
Recursive helper for mdot def _mdot_r(a, b): """Recursive helper for mdot""" if type(a) == tuple: if len(a) > 1: a = mdot(*a) else: a = a[0] if type(b) == tuple: if len(b) > 1: b = mdot(*b) else: b = b[0] return np.dot(a, b...
:param A: A DxD pd numpy array :rval Ai: the inverse of A :rtype Ai: np.ndarray :rval L: the Cholesky decomposition of A :rtype L: np.ndarray :rval Li: the Cholesky decomposition of Ai :rtype Li: np.ndarray :rval logdet: the log of the determinant of A :rtype logdet: float64 def pdinv(...
:param A: A DxDxN numpy array (each A[:,:,i] is pd) :rval invs: the inverses of A :rtype invs: np.ndarray :rval hld: 0.5* the log of the determinants of A :rtype hld: np.array def multiple_pdinv(A): """ :param A: A DxDxN numpy array (each A[:,:,i] is pd) :rval invs: the inverses of A ...
Principal component analysis: maximum likelihood solution by SVD :param Y: NxD np.array of data :param input_dim: int, dimension of projection :rval X: - Nxinput_dim np.array of dimensionality reduced data :rval W: - input_dimxD mapping from X to Y def pca(Y, input_dim): """ Principal compon...
EM implementation for probabilistic pca. :param array-like Y: Observed Data :param int Q: Dimensionality for reduced array :param int iterations: number of iterations for EM def ppca(Y, Q, iterations=100): """ EM implementation for probabilistic pca. :param array-like Y: Observed Data :pa...
returns np.dot(mat, mat.T), but faster for large 2D arrays of doubles. def tdot_blas(mat, out=None): """returns np.dot(mat, mat.T), but faster for large 2D arrays of doubles.""" if (mat.dtype != 'float64') or (len(mat.shape) != 2): return np.dot(mat, mat.T) nn = mat.shape[0] if out is None: ...
Performs a symmetric rank-1 update operation: A <- A + alpha * np.dot(x,x.T) :param A: Symmetric NxN np.array :param x: Nx1 np.array :param alpha: scalar def DSYR_blas(A, x, alpha=1.): """ Performs a symmetric rank-1 update operation: A <- A + alpha * np.dot(x,x.T) :param A: Symmetric...
Performs a symmetric rank-1 update operation: A <- A + alpha * np.dot(x,x.T) :param A: Symmetric NxN np.array :param x: Nx1 np.array :param alpha: scalar def DSYR_numpy(A, x, alpha=1.): """ Performs a symmetric rank-1 update operation: A <- A + alpha * np.dot(x,x.T) :param A: Symmetri...
Take the square matrix A and make it symmetrical by copting elements from the lower half to the upper works IN PLACE. note: tries to use cython, falls back to a slower numpy version def symmetrify(A, upper=False): """ Take the square matrix A and make it symmetrical by copting elements from t...
Return L^-T * X * L^-1, assumuing X is symmetrical and L is lower cholesky def backsub_both_sides(L, X, transpose='left'): """ Return L^-T * X * L^-1, assumuing X is symmetrical and L is lower cholesky """ if transpose == 'left': tmp, _ = dtrtrs(L, X, lower=1, trans=1) return dtrtrs(L, ...
Faster version of einsum 'ij,jlk->ilk' def ij_jlk_to_ilk(A, B): """ Faster version of einsum 'ij,jlk->ilk' """ return A.dot(B.reshape(B.shape[0], -1)).reshape(A.shape[0], B.shape[1], B.shape[2])
Faster version of einsum einsum('ijk,jlk->il', A,B) def ijk_jlk_to_il(A, B): """ Faster version of einsum einsum('ijk,jlk->il', A,B) """ res = np.zeros((A.shape[0], B.shape[1])) [np.add(np.dot(A[:,:,k], B[:,:,k]), res, out=res) for k in range(B.shape[-1])] return res
Faster version of einsum np.einsum('ijk,ljk->ilk', A, B) I.e A.dot(B.T) for every dimension def ijk_ljk_to_ilk(A, B): """ Faster version of einsum np.einsum('ijk,ljk->ilk', A, B) I.e A.dot(B.T) for every dimension """ res = np.zeros((A.shape[-1], A.shape[0], B.shape[0])) [np.dot(A[:,:,i],...
Load a previously pickled model, using `m.pickle('path/to/file.pickle)' :param file_name: path/to/file.pickle def load(file_or_path): """ Load a previously pickled model, using `m.pickle('path/to/file.pickle)' :param file_name: path/to/file.pickle """ # This is the pickling pain when changing...
numpy implementation makes use of the code here: http://se.mathworks.com/matlabcentral/fileexchange/18801-quadvgk We here use gaussian kronrod integration already used in gpstuff for evaluating one dimensional integrals. This is vectorised quadrature which means that several functions can be evaluated at the sa...
Integrate f from fmin to fmax, do integration by substitution x = r / (1-r**2) when r goes from -1 to 1 , x goes from -inf to inf. the interval for quadgk function is from -1 to +1, so we transform the space from (-inf,inf) to (-1,1) :param f: :param fmin: :param fmax: :param difftol: ...
Make an update of the internal status by gathering the variational posteriors for all the individual models. def _update_inernal(self, varp_list): """Make an update of the internal status by gathering the variational posteriors for all the individual models.""" # The probability for the binary variable...
Make an update of the internal status by gathering the variational posteriors for all the individual models. def _update_inernal(self, varp_list): """Make an update of the internal status by gathering the variational posteriors for all the individual models.""" # The probability for the binary variable...
Compute the covariance matrix between X and X2. def K(self,X,X2,target): """Compute the covariance matrix between X and X2.""" AX = np.dot(X,self.transform) if X2 is None: X2 = X AX2 = AX else: AX2 = np.dot(X2, self.transform) self.k.K(X,X2,ta...
derivative of the covariance matrix with respect to the parameters. def _param_grad_helper(self,dL_dK,X,X2,target): """derivative of the covariance matrix with respect to the parameters.""" AX = np.dot(X,self.transform) if X2 is None: X2 = X ZX2 = AX else: ...
Compute the diagonal of the covariance matrix associated to X. def Kdiag(self,X,target): """Compute the diagonal of the covariance matrix associated to X.""" foo = np.zeros((X.shape[0],X.shape[0])) self.K(X,X,foo) target += np.diag(foo)
Shape N,num_inducing,num_inducing,Ntheta def dpsi2_dtheta(self, dL_dpsi2, Z, mu, S, target): """Shape N,num_inducing,num_inducing,Ntheta""" self._psi_computations(Z, mu, S) d_var = 2.*self._psi2 / self.variance # d_length = 2.*self._psi2[:, :, :, None] * (self._psi2_Zdist_sq * self._psi...
Think N,num_inducing,num_inducing,input_dim def dpsi2_dmuS(self, dL_dpsi2, Z, mu, S, target_mu, target_S): """Think N,num_inducing,num_inducing,input_dim """ self._psi_computations(Z, mu, S) tmp = (self.inv_lengthscale2 * self._psi2[:, :, :, None]) / self._psi2_denom target_mu += -2.*(d...
Z - MxQ mu - NxQ S - NxQ def _psicomputations(self, kern, Z, variational_posterior, return_psi2_n=False): """ Z - MxQ mu - NxQ S - NxQ """ variance, lengthscale = kern.variance, kern.lengthscale N,M,Q = self.get_dimensions(Z, variational_posterior...
The SVI-VarDTC inference def inference(self, kern_r, kern_c, Xr, Xc, Zr, Zc, likelihood, Y, qU_mean ,qU_var_r, qU_var_c): """ The SVI-VarDTC inference """ N, D, Mr, Mc, Qr, Qc = Y.shape[0], Y.shape[1], Zr.shape[0], Zc.shape[0], Zr.shape[1], Zc.shape[1] uncertain_inputs_r = isi...