Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy way to grab just lower triangular values as vector from semi-metric distance calculations? #253

Open
brendanwallison opened this issue Jul 12, 2023 · 0 comments

Comments

@brendanwallison
Copy link

Hello, after running a Pairwise distance calculation with a semi-metric distance metric this package returns an NxN matrix even though it is symmetric across the diagonal.

For my purposes I need to extract just the values from the lower triangular portion for further operation. This sounds trivial (and I'm sure that it is), but it is in a differentiable loss function where I'm using Zygote, which raises an error when mutating arrays*. So if I use tril or a list comprehension to extract the values, the code errors (eg https://stackoverflow.com/questions/50651781/extract-lower-triangle-portion-of-a-matrix). The vec command doesn't, but it doesn't give me what I need.

I know that in the background if the distance is semi-metric then it's not actually calculating the redundant portion. I'm wondering if there is a quick and easy way to grab the actually unique values of the distance metric from one of these semi-metric structures, since it sounds like that may be the form it's actually in before constructing the matrix.

*In a related note, Zygote errors for colwise distance calculations but not pairwise for the same reason. This is less urgent, but is there a way to perform the colwise calculation without mutations that break Zygote automatic differentiation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant