pytorch_cluster icon indicating copy to clipboard operation
pytorch_cluster copied to clipboard

Variable K in KNN

Open mrzzmrzz opened this issue 2 years ago • 2 comments

Thank you very much for developing such a great library. Currently, I have a problem that is bothering me.

In KNN, if I want to choose the number of neighbors based on the proportion of nodes in each graph, instead of using a fixed K value, is there an efficient implementation?

I can only split the batch into separate graphs for calculation and then merge the results, but this method is not computationally efficient. So I would like to ask for your opinions on this.

mrzzmrzz avatar Apr 07 '23 06:04 mrzzmrzz

Yeah, you are right on this one. Currently, we assume fixed k across batches to keep required buffers during computation constant. Changing this would probably require a separate function. An alternative could be to utilize max(k) across all batches, and then filter invalid nodes in a post-processing step, but this may be inefficient as well if your k differs highly across examples.

rusty1s avatar Apr 09 '23 08:04 rusty1s

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?

github-actions[bot] avatar Oct 07 '23 00:10 github-actions[bot]