"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "1997b90838de45160be12179305171a60d03cc5e"
Unverified Commit 229e2883 authored by Chang Liu's avatar Chang Liu Committed by GitHub
Browse files

[Bugfix] Update dgl function `random_walk_pe` to be compatible with latest scipy (#5945)


Co-authored-by: default avatarHongzhi (Steve), Chen <chenhongzhi.nkcs@gmail.com>
parent 330571b6
...@@ -22,6 +22,7 @@ from collections.abc import Iterable, Mapping ...@@ -22,6 +22,7 @@ from collections.abc import Iterable, Mapping
import numpy as np import numpy as np
import scipy.sparse as sparse import scipy.sparse as sparse
import scipy.sparse.linalg import scipy.sparse.linalg
from packaging.version import Version
try: try:
import torch as th import torch as th
...@@ -3589,7 +3590,13 @@ def random_walk_pe(g, k, eweight_name=None): ...@@ -3589,7 +3590,13 @@ def random_walk_pe(g, k, eweight_name=None):
shape=(N, N), shape=(N, N),
) )
A = A.multiply(W) A = A.multiply(W)
RW = np.array(A / (A.sum(1) + 1e-30)) # 1-step transition probability # 1-step transition probability
if Version(scipy.__version__) < Version("1.11.0"):
RW = np.array(A / (A.sum(1) + 1e-30))
else:
# Sparse matrix divided by a dense array returns a sparse matrix in
# scipy since 1.11.0.
RW = (A / (A.sum(1) + 1e-30)).toarray()
# Iterate for k steps # Iterate for k steps
PE = [F.astype(F.tensor(RW.diagonal()), F.float32)] PE = [F.astype(F.tensor(RW.diagonal()), F.float32)]
......
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