Skip to content

Commit

Permalink
[Sparse] Fix graph_transformer example (dmlc#6471)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyuzhi authored and Ubuntu committed Nov 27, 2023
1 parent e780ca1 commit 52243a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/dgl/transforms/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3684,12 +3684,13 @@ def lap_pe(g, k, padding=False, return_eigval=False):
if k + 1 < n - 1:
# Use scipy if k + 1 < n - 1 for memory efficiency.
EigVal, EigVec = scipy.sparse.linalg.eigs(
L, k=k + 1, which="SR", tol=1e-2
L, k=k + 1, which="SR", ncv=4 * k, tol=1e-2
)
max_freqs = k
topk_indices = EigVal.argsort()[1:]
# Since scipy may return complex value, to avoid crashing in NN code,
# convert them to real number.
topk_eigvals = EigVal[topk_indices].real
topk_EigVal = EigVal[topk_indices].real
topk_EigVec = EigVec[:, topk_indices].real
else:
# Fallback to numpy since scipy.sparse do not support this case.
Expand Down

0 comments on commit 52243a7

Please sign in to comment.