Timeline for How to calculate a meaningful distance between multidimensional tensors
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 24, 2023 at 20:13 | history | edited | John St. John | CC BY-SA 4.0 |
added 25 characters in body
|
Sep 29, 2022 at 7:31 | history | edited | Edoardo Guerriero | CC BY-SA 4.0 |
added 26 characters in body
|
Jul 5, 2022 at 15:30 | comment | added | John St. John | You could do the same process using torch.cdist and the embedding output (before classification layer) of a ResNET or whatever pretrained/frozen image model. You might want to divide each embedded vector by its norm first though so you have a cosine similarity rather than a pure l2 if you do that though. Embeddings from a good image model should be better than emd, but I bet emd is a pretty good baseline. | |
Jul 5, 2022 at 14:27 | comment | added | John St. John | Nice! Glad I could help. | |
Jul 5, 2022 at 14:18 | vote | accept | Hadar Sharvit | ||
Jul 5, 2022 at 14:18 | comment | added | Hadar Sharvit | Wow, this has worked tremendously well. I highly appreciate your response. | |
Jul 5, 2022 at 13:56 | comment | added | John St. John | Or better you could flatten after doing the 3d cumsum in the example above. Then you could use cdist with p=2 to replace the subtract and square steps. You would give the function your list of per-sample flattened cumsum tensors (samples x flat) twice. Then that would be all pairwise distances with something kind of like an EMD. | |
Jul 5, 2022 at 13:53 | comment | added | John St. John | It looks like torch.cdist only supports different values of p for the L_p distance. It doesn’t look like it supports applying a function to all pairs. Sounds like you want to make a kernel matrix? You could use something like pytorch.org/docs/stable/generated/torch.combinations.html and then stack the 0,1 elements from the tuples into two tensors, then run this? | |
Jul 5, 2022 at 12:11 | comment | added | Hadar Sharvit | can this function be used within torch.cdist, to account for pairwise distances of every pair? | |
Jul 4, 2022 at 22:36 | history | edited | John St. John | CC BY-SA 4.0 |
Added normalization example
|
Jul 4, 2022 at 20:41 | history | answered | John St. John | CC BY-SA 4.0 |