I'm using DGL (Python package dedicated to deep learning on graphs) for training of defining a graph, defining Graph Convolutional Network (GCN) and train.
I faced a problem which I’m dealing with for two weeks. I developed my GCN code based on the link below:
I’m facing an error for this part of the above mentioned code:
class GCNLayer(nn.Module): def init(self, in_feats, out_feats): super(GCNLayer, self).init() self.linear = nn.Linear(in_feats, out_feats)
def forward(self, g, inputs):
# g is the graph and the inputs is the input node features
# first set the node features
g.ndata['h'] = inputs
# trigger message passing on all edges
g.send(g.edges(), gcn_message)
# trigger aggregation at all nodes
g.recv(g.nodes(), gcn_reduce)
# get the result node features
h = g.ndata.pop('h')
# perform linear transformation
return self.linear(h)
I’m getting an error below:
dgl._ffi.base.DGLError: DGLGraph.send is deprecated. As a replacement, use DGLGraph.apply_edges API to compute messages as edge data. Then use DGLGraph.send_and_recv and set the message function as dgl.function.copy_e to conduct message aggregation*
As it is guided in the error, I wonder to know how can I use DGLGraph.apply_edges instead of DGLGraph.send?
In "DGLGraph.send" command we have 2 arguments "g.edges()" and "gcn_message".
How these arguments can be converted to the arguments required for "DGLGraph.apply_edges" which are (func, edges=‘ALL’, etype=None, inplace=False ) (According to this link?
Also, the same question for "DGLGraph.send_and_recv".
In "DGLGraph.recv" we had 2 arguments "g.nodes()" and "gcn_reduce".
How these arguments can be converted to the arguments required for "DGLGraph.send_and_recv" which are "(edges, message_func, reduce_func, apply_node_func=None, etype=None, inplace=False)" (According to this link)?
I would be very grateful if you can help me with this big challenge.
Thank you
try code below, it may solve your problem