How to implement message function for heterogeneous graph?

Hi.Analogous to the model of Relational Graph Convolutional Networks (R-GCNs)

h_i^{(l+1)}=\sigma (\sum_{r \in R} \sum_{j \in N_i^r} \frac {1} {c_{i, r}} W_r^{l}h_j^{(l)}+W_0^{(l)}h_i^{(l)}),

I want to implement the following modified model

h_i^{(l+1)}=\sigma (\sum_{r \in R} \sum_{j \in N_i^r} W_r^{l}(h_j^{(l)}+h_i^{(l)}))

I think maybe I need to re-define the message function,but I don’t know how to specify the GCN-dict for different etypes in the message function.Or maybe there is another approach to implement it?Could you give me some advice?Thank you.

Are you following the RGCN-hetero example? You are right that you need to write your own GNN module since the formulation changes, and feed it to the dictionary argument for nn.HeteroGraphConv. The forward function of the per-edge-type module must have a DGLHeteroGraph object as the first argument and a tensor as the second argument representing node features. Extra arguments are accessible via mod_args and mod_kwargs. Please take a look at the docstring below.


Yes,I’ve read the rgcn-hetero.py,hetero.py and han.py.But I still don’t have idea about implementing this module.In hetero.py,what are the mod_args and mod_kwargs?These parameters are kwards for the module such as GraphConv,so maybe the activation,bias and so on.The dgl.nn.pytorch.HeteroGraphConv looks like the equation:

h_i^{(l+1)}=\sum_{r \in R} \sum_{j \in N_i^r} \phi_r^{(l)}(h_j^{(l)}),

where \phi_r^{(l)} is a function which could be fitted by neural network.
So if I want to implement the model I defined,it looks like that I need to define message function for each GraphConv of meta-path and call these re-defined GraphConv in HeteroGraphConv class.Is that it?

You are completely correct. And if your re-defined GraphConv needs some extra arguments other than the input graph and node feature, extra_args and extra_kwargs are there for your help.

Thank you very much.