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

Suggestion for improving pairwise distance calculation #14

Open
bdalal opened this issue Jul 10, 2020 · 1 comment
Open

Suggestion for improving pairwise distance calculation #14

bdalal opened this issue Jul 10, 2020 · 1 comment

Comments

@bdalal
Copy link

bdalal commented Jul 10, 2020

Hi,
Thanks for the great work on this library!
I have a small suggestion to improve the pairwise distance calculation

https://github.com/PyRetri/PyRetri/blob/master/pyretri/index/re_ranker/re_ranker_impl/k_reciprocal.py#L35-L51
I see this function being used in 3 places - kreciprocal, knn and query expansion.

This function can simple be replaced by 1 line - torch.cdist(query_fea, gallery_fea)
PyTorch's official docs don't list this function for 1.2 but it is supported (I've used it).

This change will reduce duplication and make the code more readable.

Thanks!

@hby96
Copy link
Contributor

hby96 commented Jan 21, 2021

Thanks for you suggestions! I will fix it in the next vesion.

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

2 participants