gpytorch icon indicating copy to clipboard operation
gpytorch copied to clipboard

[Feature Request] Identity Kernel

Open feynmanliang opened this issue 3 years ago • 3 comments

šŸš€ Feature Request

Sorry if this is already available, but I couldn't figure it out.

I am interested in an IdentityKernel() i.e. Kroneker delta kernel $K(x,y) = \delta_{x,y} = 1(x == y)$ which has no parameters.

Motivation

We are seeing some Cholesky decomposition errors in a GP classification problem because there is no GaussianLikelihood adding a diagonal to the marginal. To fix this, we've manually added a small diagonal matrix to the covariance. I think we can express this in the context of gpytorch kernels using an AdditiveKernel with a ScaleKernel(IdentityKernel()) and to set the outputscale to the scale of the desired noise addition.

Pitch

Describe the solution you'd like

IdentityKernel() implements gpytorch.kernels.Kernel such that IdentityKernel()(X, X) returns an identity matrix and IdentityKernel()(x,y) == x.eq(y).

Describe alternatives you've considered

We have considered adding noise manually after calling .evaluate() on the covariance LazyTensor inside of an ExactGP.forward implementation.

Are you willing to open a pull request? (We LOVE contributions!!!)

Yes, as long as this seems reasonable.

Additional context

feynmanliang avatar Sep 26 '22 23:09 feynmanliang

This seems very reasonable. We'd accept a PR!

gpleiss avatar Sep 27 '22 13:09 gpleiss

Hi Feynman, I might try to open a PR for this request if you haven't started.

ZitongZhou avatar Dec 14 '22 23:12 ZitongZhou

Go for it! I’m happy to take a look and help how I can if you get something working :)

On Wed, Dec 14, 2022 at 15:09 Zitong Zhou @.***> wrote:

Hi Feynman, I might try to open a PR for this request if you haven't started.

— Reply to this email directly, view it on GitHub https://github.com/cornellius-gp/gpytorch/issues/2146#issuecomment-1352342917, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHRW5PQBSN7IMOOAQSGFPLWNJHUBANCNFSM6AAAAAAQWIBBZU . You are receiving this because you authored the thread.Message ID: @.***>

feynmanliang avatar Dec 18 '22 05:12 feynmanliang