pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.07k stars 3.63k forks source link

How to get edge_index from unordered point clouds? #882

Open xiaomingjie opened 4 years ago

xiaomingjie commented 4 years ago

❓ Questions & Help

Almost all the graph convolutions need edge_index which is provided by some certain datasets. With those datasests such as ShapeNet whose point clouds are unordered and with no edges in them, is there any approaches to get edge_index and perform such gnns?

rusty1s commented 4 years ago

Have a look at the radius_graph and knn_graph methods. They exist both as normal functions and as transforms.

xiaomingjie commented 4 years ago

Thank you for your kindly reply. Is data.pos a matrix of n*3 which n indicates point numbers and 3 indicateds xyz coordinate?

rusty1s commented 4 years ago

Yes, but both methods do also work with any number of features (not just 3).

xiaomingjie commented 4 years ago

Thanks. Question solved.

xiaomingjie commented 4 years ago

Excuse me. When I tried to perform knn_graph, I found that I cant get data.batch in my own dataset. my data format is like [b,n,c] while knn_graph needed [n,c]. How can I perform knn_graph batch by batch?

rusty1s commented 4 years ago

You need to either reshape your data to [b*n, c] and create your batch object manually

torch.arange(0, b).view(-1, 1).repeat(1, n).view(-1)

or default to other libraries such as the KeOps library which might handle this regular case much faster :)

tchaton commented 4 years ago

Hey @xiaomingjie, have a look at https://github.com/nicolas-chaulet/deeppointcloud-benchmarks