Unverified Commit e22087aa authored by Konstantin Sofeikov's avatar Konstantin Sofeikov Committed by GitHub
Browse files

[BUG] fix for zero degree nodes (#2786)



* fix for zero degree nodes

* Update python/dgl/ops/spmm.py

linting fix
Co-authored-by: default avatarZihao Ye <zihaoye.cs@gmail.com>
Co-authored-by: default avatarKonstantin Sofeikov <konstantin.sofeikov@complyadvantage.com>
Co-authored-by: default avatarZihao Ye <expye@outlook.com>
Co-authored-by: default avatarZihao Ye <zihaoye.cs@gmail.com>
parent 0b57ce18
...@@ -70,7 +70,7 @@ def gspmm(g, op, reduce_op, lhs_data, rhs_data): ...@@ -70,7 +70,7 @@ def gspmm(g, op, reduce_op, lhs_data, rhs_data):
if reduce_op == 'mean': if reduce_op == 'mean':
ret_shape = F.shape(ret) ret_shape = F.shape(ret)
deg = g.in_degrees() deg = g.in_degrees()
deg = F.astype(F.clamp(deg, 1, g.number_of_edges()), F.dtype(ret)) deg = F.astype(F.clamp(deg, 1, max(g.number_of_edges(), 1)), F.dtype(ret))
deg_shape = (ret_shape[0],) + (1,) * (len(ret_shape) - 1) deg_shape = (ret_shape[0],) + (1,) * (len(ret_shape) - 1)
return ret / F.reshape(deg, deg_shape) return ret / F.reshape(deg, deg_shape)
else: else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment