When I use many small images as the input of dgl.batch, I get the following results:
Graph(num_nodes=176, num_edges=168,
ndata_schemes={‘iid’: Scheme(shape=(), dtype=torch.int32), ‘last’: Scheme(shape=(), dtype=torch.int32)}
edata_schemes={}
When I use it as the input of dgl.nn.GataedGraphConv, how should I get the corresponding node according to each original graph
sorry,maybe I didn’t explain my question clearly…
such as:
import dgl
import numpy as np
import torch as th
from dgl.nn import GatedGraphConv
g = dgl.batch([g1, g2, g3, g4])
conv = GatedGraphConv(10, 10, 2, etype)
res = conv(g, feat, etype)
res
The result obtained here is the representation of all nodes after multiple small graphs in a batch form a large graph, how can I restore the result to the nodes of each subgraph,thank you!
For example, data.batch = torch.tensor([0, 1, 1, 2, 3, 4]) in pyg, where 0 represents the node in the first subgraph, by analogy, the second and third nodes is the node of the second subgraph
You can do
g.ndata['h'] = res
g1, g2, g3, g4 = dgl.unbatch(g)
thank you for your reply!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.