Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix the bug of average degree
  • Loading branch information
HPUtx813 committed Mar 7, 2024
commit ac69684c3802ca22ab8c30f8e92ba59a9db76ad4
4 changes: 3 additions & 1 deletion dhg/nn/convs/hypergraphs/unignn_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def forward(self, X: torch.Tensor, hg: Hypergraph) -> torch.Tensor:
# compute the special degree of hyperedges
_De = torch.zeros(hg.num_e, device=hg.device)
# scatter_reduce() is relay on the torch 1.12.1, which may be updated in the future
_De = _De.scatter_reduce(0, index=hg.v2e_dst, src=hg.D_v.clone()._values()[hg.v2e_src], reduce="mean")
_Dv = hg.D_v.clone()._values()[hg.v2e_src]
_De = _De.scatter_reduce(0, index=hg.v2e_dst, src=_Dv, reduce="sum") / _De.scatter_reduce(
0, index=hg.v2e_dst, src=(_Dv != 0).type_as(_De), reduce="sum")
_De = _De.pow(-0.5)
_De[_De.isinf()] = 1
Y = _De.view(-1, 1) * Y
Expand Down