question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rusty1scommented, Oct 13, 2022

@LukeLIN-web The implementation is here.

1reaction
rusty1scommented, Oct 10, 2022

At best, we use the implementation from pyg-lib as used in the NeighborLoader, see here. It is documented here.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found