我正在使用DGL(用于图表上深度学习的Python软件包)来定义图,定义图形卷积网络(GCN)和火车。
我遇到了一个问题,我已经处理了两个星期。
我根据下面的链接开发了我的GCN代码:
我在上述代码的这一部分面临错误:
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)
我在下面遇到一个错误:
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*
在错误的指导下,我想知道如何使用dglgraph.apply_edges “ dglgraph.send” 命令中的不是dglgraph.send?
,我们有2个参数“ g.edges()” 和和“ gcn_message” 。
如何将这些参数转换为“ dglgraph.apply_edges” 的参数()根据此
另外,“ dglgraph.send_and_recv” 。
在“ dglgraph.recv”中 的同一问题。 和“ gcn_reduce”
。 redy_func,apply_node_func = none,eType = none,intplace = false = false)” (根据此 link )?
如果您能帮助我解决这个巨大的挑战。
谢谢
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:
enter link description here
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
发布评论
评论(2)
DGLGraph.apply_edges(func, Edges='ALL', etype=None, inplace=False) 用于在 'edges' 中的所有边上使用函数 'func' 来更新边特征。
DGLGraph.send_and_recv(edges, message_func, reduce_func, apply_node_func=None, etype=None, inplace=False) 用于传递消息、减少消息并更新 'edges' 中所有边的节点特征。
要使您的转发方法发挥作用,您可以更新您的代码,如下所示
您可以使用您自己的 message_func (消息生成)和 reduce_func (消息聚合)来满足您的目的。
DGLGraph.apply_edges(func, edges='ALL', etype=None, inplace=False) is used to update edge features using the function 'func' on all the edges in 'edges'.
DGLGraph.send_and_recv(edges, message_func, reduce_func, apply_node_func=None, etype=None, inplace=False) is used to pass messages, reduce messages and update the node features for all the edges in 'edges'.
To get your forward method to work you can update your code as below
You can use your own message_func (message generation) and reduce_func (message aggregation) to fit your purpose.
尝试下面的代码,它可能会解决您的问题
try code below, it may solve your problem