Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
09c33b9f
Unverified
Commit
09c33b9f
authored
Oct 19, 2023
by
xiangyuzhi
Committed by
GitHub
Oct 19, 2023
Browse files
[Sparse] Fix graph_transformer example (#6471)
parent
101d2ae9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
python/dgl/transforms/functional.py
python/dgl/transforms/functional.py
+3
-2
No files found.
python/dgl/transforms/functional.py
View file @
09c33b9f
...
@@ -3684,12 +3684,13 @@ def lap_pe(g, k, padding=False, return_eigval=False):
...
@@ -3684,12 +3684,13 @@ def lap_pe(g, k, padding=False, return_eigval=False):
if
k
+
1
<
n
-
1
:
if
k
+
1
<
n
-
1
:
# Use scipy if k + 1 < n - 1 for memory efficiency.
# Use scipy if k + 1 < n - 1 for memory efficiency.
EigVal
,
EigVec
=
scipy
.
sparse
.
linalg
.
eigs
(
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
:]
topk_indices
=
EigVal
.
argsort
()[
1
:]
# Since scipy may return complex value, to avoid crashing in NN code,
# Since scipy may return complex value, to avoid crashing in NN code,
# convert them to real number.
# convert them to real number.
topk_
e
ig
v
al
s
=
EigVal
[
topk_indices
].
real
topk_
E
ig
V
al
=
EigVal
[
topk_indices
].
real
topk_EigVec
=
EigVec
[:,
topk_indices
].
real
topk_EigVec
=
EigVec
[:,
topk_indices
].
real
else
:
else
:
# Fallback to numpy since scipy.sparse do not support this case.
# Fallback to numpy since scipy.sparse do not support this case.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment