rusty1s / pytorch_cluster

PyTorch Extension Library of Optimized Graph Cluster Algorithms
MIT License
780 stars 142 forks source link

Random walk with custom transition probabilities #88

Open jinga-lala opened 3 years ago

jinga-lala commented 3 years ago

Is there any way to call random_walk function with custom transition probabilities?

rusty1s commented 3 years ago

Currently no. I think one can implement it via alias sampling.

jinga-lala commented 3 years ago

Are you referring to this function? https://github.com/rusty1s/pytorch_cluster/blob/4764b48be5f18ad9b20683571c70d8fa690abae2/torch_cluster/rw.py#L8

If yes, I am sorry but I don't understand this function because it seems you are returning the same function again. If possible can you write the exact code snippet? Any help would be appreciated.

rusty1s commented 3 years ago

torch.ops.torch_cluster.random_walk calls the underlying CPU/CUDA implementation in csrc/cpu/rw_cpu.cpp and csrc/cuda/rw_cuda.cu. These implementations cannot currently handle custom transition probabilities.

jinga-lala commented 3 years ago

Thanks for your reply. Can you please write a wrapper over this function to handle transition probabilities, probably using alias sampling as you mentioned earlier?

rusty1s commented 3 years ago

I see what I can do :)

ChainlessCoder commented 3 years ago

This would be an extremely useful feature... As of now it's kinda tricky to do weighted random walks for e.g. node embeddings :/