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
924c5669
Unverified
Commit
924c5669
authored
Feb 08, 2024
by
Andrei Ivanov
Committed by
GitHub
Feb 09, 2024
Browse files
Fixing problem with complex numbers appearing in the `lap_pe` function. (#6925)
parent
6735a3ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
python/dgl/transforms/functional.py
python/dgl/transforms/functional.py
+5
-6
No files found.
python/dgl/transforms/functional.py
View file @
924c5669
...
...
@@ -3688,10 +3688,6 @@ def lap_pe(g, k, padding=False, return_eigval=False):
)
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_EigVal
=
EigVal
[
topk_indices
].
real
topk_EigVec
=
EigVec
[:,
topk_indices
].
real
else
:
# Fallback to numpy since scipy.sparse do not support this case.
EigVal
,
EigVec
=
np
.
linalg
.
eig
(
L
.
toarray
())
...
...
@@ -3699,8 +3695,11 @@ def lap_pe(g, k, padding=False, return_eigval=False):
kpartition_indices
=
np
.
argpartition
(
EigVal
,
max_freqs
)[:
max_freqs
+
1
]
topk_eigvals
=
EigVal
[
kpartition_indices
]
topk_indices
=
kpartition_indices
[
topk_eigvals
.
argsort
()][
1
:]
topk_EigVec
=
EigVec
[:,
topk_indices
]
topk_EigVal
=
EigVal
[
topk_indices
]
# Since scipy may return complex value, to avoid crashing in NN code,
# convert them to real number.
topk_EigVal
=
EigVal
[
topk_indices
].
real
topk_EigVec
=
EigVec
[:,
topk_indices
].
real
eigvals
=
F
.
tensor
(
topk_EigVal
,
dtype
=
F
.
float32
)
# get random flip signs
...
...
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