I have many graphs and want to perform node regression as follow:
- do message passing between nodes (as in normal node-level task)
- do message passing between nodes (independent from first) and readout to get single vector for graph
(as in normal graph-level task)
and then make node regression using data from 1 and 2, ie. concatenate node features with graph features (one and the same vector for whole graph, but each single graph has it own graph features).
Forward function for first should looks like
def forward(self, g, h):
h = F.relu(self.conv1(g, h))
h = F.relu(self.conv2(g, h))
return h
for the second like:
def forward(self, g, h):
h = F.relu(self.conv1(g, h))
h = F.relu(self.conv2(g, h))
with g.local_scope():
g.ndata['h'] = h
hg = dgl.mean_nodes(g, 'h')
return self.linear(hg)
but how it should look like when I want to use both local (node-level) and global (graph-level) features?