K-NNGraph: make k variable for batched examples #4801
RasmusOrsoe
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
I think this is a good feature request, thanks for sharing. This would need to be implemented in |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey!
I use
torch_geometric.transforms.KNNGraph
quite often, and on data where the number of nodes in a graph can vary quite a bit. Having a fixed k for all examples in a batch is suboptimal. In terms of optimization, it could be very nice to specify a k for each example in a batch of graphs. This could be achieved by makingKNNGraph
accept a list as argument for k.Mock-example:
Let's say we have
batch_size = 5
, so 5 graphs in a batch, and that the number of nodes in the graphs are:[10, 4, 30, 50, 8]
.Instead of specifying a fixed k for the entire batch, one could pass a list of k's. In this case, perhaps something like
k = [3, 2, 8, 10, 3]
such that the edge index for the first graph is calculated usingk = 3
, andk=2
for the second graph,k = 8
for the third, and so on.I can write a dirty for-loop to achieve this, but it's highly inefficient. Any ideas on how to implement this?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions