pytorch_geometric icon indicating copy to clipboard operation
pytorch_geometric copied to clipboard

Support multiple node type sampling in NeighborLoader (V2)

Open Padarn opened this issue 3 years ago • 7 comments

This PR adds functionality to allow for multiple node types to be sampled in NeighbourLoader.

The interface looks as was discussed in the roadmap (https://github.com/pyg-team/pytorch_geometric/issues/4765):

NeighbourLoader(
   input_nodes=dict(
     paper=torch.LongTensor([0,1,2]), 
     author=torch.LongTensor([0,1,2])
    )
  ...
)

Internally, it converts this to a list of tuples.

[('paper', 0), ('paper', 1),....]

This is not very efficient, but benchmarks https://github.com/pyg-team/pytorch_geometric/issues/4765#issuecomment-1147105584 showed it to be acceptable.

TODO:

  • [ ] Add tests

Addresses https://github.com/pyg-team/pytorch_geometric/issues/4765

cc @mananshah99

Padarn avatar Sep 24 '22 10:09 Padarn

@mananshah99 I was trying to figure out how to cleanly add this, and the easiest seemed to be to do something like what I've done here: Wrapping the 'input nodes' up into a class.

I know the code is probably not in the right place, and I've not actually used it to support multiple nodes yet, but I wanted to get feedback on this approach.

Padarn avatar Sep 24 '22 10:09 Padarn

Sorry, just saw this in my inbox. Will have a review in shortly

mananshah99 avatar Oct 15 '22 00:10 mananshah99

hey just a bump @mananshah99 :-)

Padarn avatar Oct 23 '22 00:10 Padarn

I'll try to get this merged today. Sorry for the slowness on our end :)

rusty1s avatar Oct 24 '22 06:10 rusty1s

thanks! but actually its no where near ready for merging - just looking for feedback on the approach before I implement it more thoroughly

Padarn avatar Oct 25 '22 08:10 Padarn

Your understanding is correct. Thanks for the feedback.

I will finish the implementation taking your comments into account 👍

Padarn avatar Nov 08 '22 08:11 Padarn

Your understanding is correct. Thanks for the feedback.

I will finish the implementation taking your comments into account 👍

Hi @Padarn, thanks for your contributioooon!! Would you still be interested on finishing it? It would be amazing to have this feature

denadai2 avatar Mar 10 '24 13:03 denadai2