Replies: 6 comments 8 replies
-
Hi. Maybe you can take a look at >>> edge_index = torch.LongTensor([[0, 100], [100, 0]])
>>> edge_index
tensor([[ 0, 100],
[100, 0]])
>>> from torch_geometric.utils import remove_isolated_nodes
>>> edge_index = remove_isolated_nodes(edge_index)[0]
>>> edge_index
tensor([[0, 1],
[1, 0]]) |
Beta Was this translation helpful? Give feedback.
-
it is ok.edge_index exists some self-loop |
Beta Was this translation helpful? Give feedback.
-
By the way,how to get original edge_index? |
Beta Was this translation helpful? Give feedback.
-
edge_index_remain, _, mask = remove_isolated_nodes(edge_index)
edge_mask = torch.logical_and(mask[edge_index[0]], mask[edge_index[1]])
edge_index[:, edge_mask] |
Beta Was this translation helpful? Give feedback.
-
Since the characteristics of isolated nodes are still helpful for GNN training, can we rearrange the nodes while preserving the self loop? |
Beta Was this translation helpful? Give feedback.
-
import torch
edge_index = torch.tensor([[100, 200, 300, 400], [200, 300, 400, 500]])
>>> edge_index
tensor([[100, 200, 300, 400],
[200, 300, 400, 500]])
>>> _, edge_index = torch.unique(edge_index, return_inverse=True)
>>> edge_index
tensor([[0, 1, 2, 3],
[1, 2, 3, 4]]) Is that what you want? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How to get rearranged edge_index?
my edge_index:
But it only has 106 nodes,how to Rearrange edge_index so that its value range is:[0,105]
for example:
Beta Was this translation helpful? Give feedback.
All reactions