SheffieldML / GPy

Gaussian processes framework in python
BSD 3-Clause "New" or "Revised" License
2.04k stars 562 forks source link

What is the definition of gradients_X_diag? #665

Closed PAC-Bayesian closed 6 years ago

PAC-Bayesian commented 6 years ago

Hi,

I am trying to implement a new kernel, but a little bit confused about the following methods in the root class Kern in GPy.kern.src.kern:

def gradients_X(self, dL_dK, X, X2):
        """
        .. math::

            \\frac{\partial L}{\partial X} = \\frac{\partial L}{\partial K}\\frac{\partial K}{\partial X}
        """
        raise NotImplementedError
 def gradients_X_diag(self, dL_dKdiag, X):
        """
        The diagonal of the derivative w.r.t. X
        """
        raise NotImplementedError

It seems both should return an array of the same shape of X.

My questions are: Does gradients_X_diag only involve calculations from Kdiag? Or is it equivalent to gradients_X(self, np.diag(dL_dK), X, X)?

Thank you!

mzwiessele commented 6 years ago

Yes the first option is right. It only involves the gradients of the diagonal of the covariance matrix.