Skip to content

Commit

Permalink
[Fix] normalize by dst if edge_weight is None (dmlc#3744)
Browse files Browse the repository at this point in the history
* [Fix] normalize by dst if edge_weight is None

* [Doc] fix math formula display issue
  • Loading branch information
Rhett-Ying authored Feb 17, 2022
1 parent 8a8d36e commit 22272de
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions python/dgl/nn/pytorch/conv/appnpconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def forward(self, graph, feat, edge_weight=None):
edge_weight: torch.Tensor, optional
edge_weight to use in the message passing process. This is equivalent to
using weighted adjacency matrix in the equation above, and
:math:\tilde{D}^{-1/2}\tilde{A} \tilde{D}^{-1/2}
:math:`\tilde{D}^{-1/2}\tilde{A} \tilde{D}^{-1/2}`
is based on :class:`dgl.nn.pytorch.conv.graphconv.EdgeWeightNorm`.
Returns
Expand Down Expand Up @@ -114,10 +114,9 @@ def forward(self, graph, feat, edge_weight=None):
if edge_weight is None:
feat = feat * src_norm
graph.ndata['h'] = feat
if edge_weight is None:
edge_weight = th.ones(graph.number_of_edges(), 1)
graph.edata['w'] = self.edge_drop(
edge_weight).to(feat.device)
w = th.ones(graph.number_of_edges(),
1) if edge_weight is None else edge_weight
graph.edata['w'] = self.edge_drop(w).to(feat.device)
graph.update_all(fn.u_mul_e('h', 'w', 'm'),
fn.sum('m', 'h'))
feat = graph.ndata.pop('h')
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/nn/pytorch/conv/gcn2conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def forward(self, graph, feat, feat_0, edge_weight=None):
edge_weight: torch.Tensor, optional
edge_weight to use in the message passing process. This is equivalent to
using weighted adjacency matrix in the equation above, and
:math:\tilde{D}^{-1/2}\tilde{A} \tilde{D}^{-1/2}
:math:`\tilde{D}^{-1/2}\tilde{A} \tilde{D}^{-1/2}`
is based on :class:`dgl.nn.pytorch.conv.graphconv.EdgeWeightNorm`.
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/nn/pytorch/conv/sgconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def forward(self, graph, feat, edge_weight=None):
edge_weight: torch.Tensor, optional
edge_weight to use in the message passing process. This is equivalent to
using weighted adjacency matrix in the equation above, and
:math:\tilde{D}^{-1/2}\tilde{A} \tilde{D}^{-1/2}
:math:`\tilde{D}^{-1/2}\tilde{A} \tilde{D}^{-1/2}`
is based on :class:`dgl.nn.pytorch.conv.graphconv.EdgeWeightNorm`.
Returns
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/nn/pytorch/conv/tagconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def forward(self, graph, feat, edge_weight=None):
edge_weight: torch.Tensor, optional
edge_weight to use in the message passing process. This is equivalent to
using weighted adjacency matrix in the equation above, and
:math:\tilde{D}^{-1/2}\tilde{A} \tilde{D}^{-1/2}
:math:`\tilde{D}^{-1/2}\tilde{A} \tilde{D}^{-1/2}`
is based on :class:`dgl.nn.pytorch.conv.graphconv.EdgeWeightNorm`.
Returns
Expand Down

0 comments on commit 22272de

Please sign in to comment.