Skip to content

how to build a customer MultiOutput kernels ? #1504

Answered by gpleiss
linkzhao asked this question in Q&A
Discussion options

You must be logged in to vote

I think there may have been a few typos in @arthus701 's suggestion. Here's my attempt.
Again, this is un tested. I've commented what all the shapes should be.

A debugging tip: make sure the sizes of the object actually match the sizes in the comments.

from gpytorch.lazy import KroneckerLazyProduct

def forward(self, x1, x2, **params):
    # THIS IS JUST A CRUDE SKETCH! DON'T TAKE ANYTHING HERE FOR GRANTED!
    n = x1.size(-2)
    m = x2.size(-2)
    d = x1.size(-1)
    
    x1 = x1 / self.lengthscale
    x2 = x2 / self.lengthscale
    
    # Diff tensor: ... x n x m x d
    diff = x1.unsqueeze(-2) - x2.unsqueeze(-3)
    
    # Outer product term
    outer = diff.unsqueeze(-1) - diff.unsq…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
7 replies
@linkzhao
Comment options

@arthus701
Comment options

@linkzhao
Comment options

@arthus701
Comment options

@linkzhao
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by gpleiss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants