how transform adj of shape BN×BN to B×N×N #4690
Answered
by
rusty1s
zhinanchezhoubo
asked this question in
Q&A
-
I have a batch dataset, which is obtained from torch_geometric.loader, the dataset is such as: Batch(edge_attr=[2560, 4], edge_index=[2, 2560], x=[1154, 7], y=[64], batch=[1154], ptr=[65]), i want wo get the adj of the batch dataset, if i use torch_geometric.utils.to_dense_adj(edge_index,batch) will obtain a adj of 1154×1154,but i want to get the adj shape is B×N×N,B is subgraph number ,N is the max nodes number of subgraph. How can i do it? |
Beta Was this translation helpful? Give feedback.
Answered by
rusty1s
May 21, 2022
Replies: 1 comment 5 replies
-
Do you have a small example to reproduce? This works just fine for me: from torch_geometric.data import Batch
from torch_geometric.utils import to_dense_adj
from torch_geometric.datasets import TUDataset
dataset = TUDataset('/tmp/TU', name='MUTAG')
batch = Batch.from_data_list(dataset[:10])
adj = to_dense_adj(batch.edge_index, batch.batch)
print(adj.shape) |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
zhinanchezhoubo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have a small example to reproduce? This works just fine for me: