How to combine DGL with other neural network models?

Hi, DGL is a graceful tool for graph learning.
However, it seems that there is no tutorial or examples in DGL to combine the existing models easily?
For example,

G.ndata['feature'] = features

note the node features are derived from other modules (e.g., a CNN/RNN feature extractor), so in this way, would the whole pytorch computation graph be complete for backpropagation?

Or, if we have obtained the results of GCN Layers, such as:

x = self.gcn1(g, features)
x = self.gcn2(g, x)

If I continue to conduct other operations on x or part columns of x, can the computation graph be complete?
Thanks.

Hi,

Everything in DGL will maintain the backpropagation trace. You can use this with other model in any way as you want.

Thanks. I’ll try it to combine with others.

@htliu Hi, this is a very interesting problem and I wonder if you have solved it. Could you show some examples in code?

Thanks a lot.

1 Like

Hi, I have one question. I am also new to DGL and I am wondering when you feed features to a graph like the following:

G.ndata['feature'] = features

Does the first row in feature corresponds to the node with node id 0 in the graph?

Thanks~

Yeah, hence the dimensions should be consistent.

1 Like

Yes, the i-th row of features always corresponds to the node i in the graph.