How to apply DGL to myself-defined network structure

Hi there
I have some trouble with how to apply dgl to myself-defined network structure.
The following is an example of a custom network structure. If I want to implement an input as a graph and an output as a number, the intermediate process is to do T Message Passing on a 2 layer fully connected network and an RNN network (or LSTM network), and finally get a number. My understanding is that two layers of the corresponding aggregate function to connect to the Internet, RNN (or LSTM) is the corresponding update function, and finally read function can be embedding value addition to get a value.
The network structure consists of three layers
layer1 = linear()
layer2 = linear()
layer3 = rnn()
layer4 = readout()
How to use DGL to deliver T messages, can I use mini-batch to train my network?

What explicit task are you working on? If your input is a graph, how can you apply an RNN to it? Do you have a paper reference for the model you described?

Thanks for your reply. My task is using GNN to compute DQN-modeling’s Q-value. The paper I refer to are as follow:[《Deep Reinforcement Learning meets Graph Neural Networks: exploring a routing optimization use case》](https://arXiv:1910.07421v2 [cs.NI] 14 Feb 2020)

My main question is, how do I represent T Message Passing

It looks like the architecture is very similar to the Message Passing Neural Network. For a reference, see the computation here.

1 Like

Blockquote

Thanks for your reply. I have finished reading the code you recommend. There is a question.What if I only use nodes’ feature or edges’ feature instead of both them to realize the MPNN process, can I still use NNConv layer?

You can probably adapt NNConv so that it is still meaningful when you only have node features or edge features. However, I wonder if it will be better to use another model in that case.

You are so sweet to answer my question! Actually, I have tried many other GNN models, such as GIN, GAT and so on. I always met trouble with adjusting these models to my own problem. User-defined function makes me confuse, is there any easy course or tips to make it easy?

In other words, can DGL implement edge features in the graph for message passing? For example, edge features are updated from all edge features adjacent to it. This process seems to have nothing to do with node features, but DGL does not seem to have a solution for this situation. I am so confused.

Does FAQ 13 here help? The computation of GNNs is node-centric. One possibility is to project edge features by an MLP after each layer. Another possibility is to generate node representations from edge features first and then only update node representations in the rest GNN layers.

1 Like

I have read the FAQ 13 ,some answers do help me with DGL. I am agree with that GNN is a node-centric framework,The MPNN messaging mechanism treats edges as message delivery paths. I‘ve already considered projecting edge features as node representations, but was a little worried that I would have difficulty training satisfactory results in my own task. It’s very hard to reach a tradeoff.

For the first solution, the inputs to the model are edges features, so the first layer of GNN can not work. Am I mistaken with it?

Yes, you will need to compute initial node representations from edge features, e.g., take the average of edge representations of the incoming edges.

1 Like