question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Using `GPyTorch` with a distance matrix or covariance matrix as input

See original GitHub issue

Hi! Thanks for providing this nice tool for us!!

My question is it possible to use a symmetric pairwise distance matrix or a covariance matrix from the distance matrix as an input, instead of the conventional used X_train? In the examples given in the documentation, we use use X_train and y_train and the kernel function we select will transform our X_train into a covariance matrix. But in my case, I can only compute the distance matrix.

Any suggestions would be appreciated. Thanks!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Balandatcommented, Jul 23, 2021

Cool stuff. It should be possible to do this by using the components of the prediction strategies - take a look here: https://github.com/cornellius-gp/gpytorch/blob/master/gpytorch/models/exact_prediction_strategies.py#L249-L264

1reaction
FanwangMcommented, Jul 23, 2021

I have an in-house algorithm to get the distance/dissimilarity between two objects. Then I have some objects and I have computed pair-wise distances. This gives me a chance to build a covariance matrix from distance, such as a Matern kernel/covariance. I don’t have coordinates of the objects, which makes the problem a little bit hard to use build-in kernels in gpytorch. I don’t need a complicated kernel. I am looking for something like this in GPyTorch, https://gist.github.com/amueller/1351047.

Hope this is a little bit helpful. @Balandat

Read more comments on GitHub >

github_iconTop Results From Across the Web

torch.cdist — PyTorch 1.13 documentation
Computes batched the p-norm distance between each pair of the two collections of row vectors. Parameters: x1 (Tensor) – input tensor of shape...
Read more >
Pairwise similarity matrix between a set of vectors in PyTorch
A partial answer to the question, for the case of Euclidean distance/similarity (or more generally any p-norm distance), but NOT for Cosine  ......
Read more >
How to Compute the Pseudoinverse of a Matrix in PyTorch
linalg.pinv() method accepts a matrix and a batch of matrices as input and returns a new tensor with the pseudoinverse of the input...
Read more >
How to vectorize pairwise (dis)similarity metrics | by Ben Cook
The input to that algorithm is a cost matrix where each element is the ... PyTorch and TensorFlow) is that you can use...
Read more >
Mahalanobis Distance - Understanding the math with ...
What's wrong with using Euclidean Distance for Multivariate data? ... We then divide this by the covariance matrix (or multiply by the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found