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

Inconsistent number of neighbors being returned from knn_graph #40

Closed
SergioRAgostinho opened this issue Dec 17, 2019 · 5 comments
Closed
Labels

Comments

@SergioRAgostinho
Copy link

Version: 1.4.5

I'm getting an inconsistent number of nearest neighbours being returned from from knn_graph (cuda). I'll try to provide the actual data later. Currently I'm invoking the method as

edge_index = knn_graph(P, k=5, batch=batch, loop=False)

P is of dim [2048, 64], composed of a single batch
batch is a vector of zeros size 2048
The flow is set to its default value source_to_target.

edge_index is showing the following values

# everything fine with this one. 5 neighbours per point
(Pdb) edge_index[1,:16]
tensor([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3], device='cuda:0')
# at the end there are problems. indexes 2046 and 2047 are showing 6 times neighbours instead of 5
(Pdb) edge_index[1,-16:]
tensor([2045, 2045, 2045, 2045, 2046, 2046, 2046, 2046, 2046, 2046, 2047, 2047,
        2047, 2047, 2047, 2047], device='cuda:0')
@SergioRAgostinho
Copy link
Author

data.zip

Extract the archive and load the data with torch.load. It's a dictionary object containing the contents of P, batch and edge_index.

@rusty1s
Copy link
Owner

rusty1s commented Dec 17, 2019

Thank you! I will have a look.

@rusty1s
Copy link
Owner

rusty1s commented Jan 6, 2020

Ok, I identified the issue. All entries in P are equal, so removing self-loops leads to an undefined behaviour since the loop may or may not be included in the initial edge_index. I am not really sure if this needs to be fixed since this is an untypical use-case for knn_graph.

@SergioRAgostinho
Copy link
Author

All entries in P are equal

Ok weird. If I'm interpreting what you wrote correctly, it means I missed a pretty naive mistake during debug. It wouldn't be the first time 🤷‍♂️. I'll recheck things.

@github-actions
Copy link

This issue had no activity for 6 months. It will be closed in 2 weeks unless there is some new activity. Is this issue already resolved?

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

No branches or pull requests

2 participants