k_hop_subgraph cannot maintain that the actual mini-batch nodes always be placed first
See original GitHub issue🛠 Proposed Refactor
I am glad to find that actual mini-batch nodes always be placed first
https://github.com/pyg-team/pytorch_geometric/discussions/5279#discussioncomment-3814170
But
https://github.com/pyg-team/pytorch_geometric/blob/2d77047811311544d4861fa9e80fd2ec60ab6d01/torch_geometric/utils/subgraph.py#L302
unique
always always sort the tensor link
So that it cannot maintain that the actual mini-batch nodes always be placed first.
Suggest a potential alternative/fix
I just use set.
origin_nodes = set([node_idx])
for i in range(1,num_hops):
subsets[i] = subsets[i][~np.isin(subsets[i],origin_nodes)]
But I don’t know how to return_inverse correctly.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
torch_geometric.utils.subgraph - PyTorch Geometric
Args: subset (LongTensor, BoolTensor or [int]): The nodes to keep. edge_index ... optional): If set to :obj:`True`, will return the edge mask to...
Read more >Ripple Walk Training: A Subgraph-based Training Framework ...
A novel sampling method Ripple Walk Sampler works for sampling these high-quality subgraphs to constitute the mini-batch, which considers both ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@LukeLIN-web The implementation is here.
At best, we use the implementation from
pyg-lib
as used in theNeighborLoader
, see here. It is documented here.