rusty1s/pytorch_cluster

Variable K in KNN

mrzzmrzz opened this issue · 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.

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.

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?