Additional option for `torch_geometric.utils.subgraph`
See original GitHub issue🚀 The feature, motivation and pitch
I’ve come across dropout_node
again and I found an unexpected behavior for this function. For an example provided in the doc-string:
>>> edge_index = torch.tensor([[0, 1, 1, 2, 2, 3],
... [1, 0, 2, 1, 3, 2]])
>>> edge_index, edge_mask, node_mask = dropout_node(edge_index)
>>> edge_index
tensor([[0, 1],
[1, 0]])
>>> edge_mask
tensor([ True, True, False, False, False, False])
>>> node_mask
tensor([ True, True, False, False])
Actually, we need to remove all edges that contained the dropped nodes [0, 1]
, but subgraph
only drops edges that both ends are in the subset [0,1]
:
https://github.com/pyg-team/pytorch_geometric/blob/081a964638459d1374f2e90de8ccfc9f0ea1f043/torch_geometric/utils/subgraph.py#L98
So in this case it should be |
rather than &
in the above code? Should we add an additional option to support this?
Alternatives
Add an option for subgraph
to support |
rather than &
in some cases.
https://github.com/pyg-team/pytorch_geometric/blob/081a964638459d1374f2e90de8ccfc9f0ea1f043/torch_geometric/utils/subgraph.py#L98
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
torch_geometric.utils — pytorch_geometric documentation
Computes the induced subgraph of edge_index around all nodes in node_idx reachable within k ... See the documentation of torch-scatter for more information....
Read more >torch_geometric.utils.subgraph - PyTorch Geometric
Source code for torch_geometric.utils.subgraph ... optional): If set to :obj:`True`, will return the edge mask to filter out additional edge features.
Read more >torch_geometric.utils — pytorch_geometric 2.0.1 documentation
Computes the k -hop subgraph of edge_index around node node_idx . homophily. The homophily of a graph characterizes how likely nodes with the...
Read more >torch_geometric.utils.subgraph — pytorch_geometric 1.3.2 ...
Source code for torch_geometric.utils.subgraph. import torch from .num_nodes import maybe_num_nodes. [docs]def subgraph(subset, edge_index, edge_attr=None, ...
Read more >torch_geometric.utils.subgraph — pytorch_geometric 2.0.1 ...
Source code for torch_geometric.utils.subgraph. import torch from .num_nodes import maybe_num_nodes. [docs]def subgraph(subset, edge_index, edge_attr=None, ...
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
Sorry for the confusion. Don’t we already do this?
only maintains the edges for which both endpoints are in the non-dropped node set.
Oh you are right, my bad. Everything looks okay, sorry for the wasted time here.