Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add random walk based AddRandomMetaPaths as a faster alternative #5397

Merged
merged 25 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2716266
add AddMetaPath2 as a faster alternative
EdisonLeeeee Sep 9, 2022
c1cec1c
remove redundant code
EdisonLeeeee Sep 10, 2022
544c416
Update torch_geometric/transforms/add_metapaths.py
EdisonLeeeee Sep 14, 2022
f4f138d
Update torch_geometric/transforms/add_metapaths.py
EdisonLeeeee Sep 14, 2022
8bd110a
rename
EdisonLeeeee Sep 15, 2022
8b2ea69
add __repr__
EdisonLeeeee Sep 15, 2022
d5d6874
add test
EdisonLeeeee Sep 15, 2022
4d6e4db
Merge branch 'master' into add_metapath
EdisonLeeeee Sep 15, 2022
97de0f5
coalesce edges
EdisonLeeeee Sep 17, 2022
8751ac6
Merge branch 'master' into add_metapath
EdisonLeeeee Sep 17, 2022
a3e0990
Merge branch 'master' into add_metapath
EdisonLeeeee Sep 20, 2022
05c6c4f
Update torch_geometric/transforms/add_metapaths.py
EdisonLeeeee Sep 20, 2022
72a56e2
Update torch_geometric/transforms/add_metapaths.py
EdisonLeeeee Sep 20, 2022
1cc5e63
Update torch_geometric/transforms/add_metapaths.py
EdisonLeeeee Sep 20, 2022
123de91
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 20, 2022
d013a67
update
EdisonLeeeee Sep 20, 2022
d613123
Merge branch 'master' into add_metapath
EdisonLeeeee Sep 20, 2022
0a1e5ec
Rename some variables + update docs.
wsad1 Sep 20, 2022
e69ab6b
Refactor to share code.
wsad1 Sep 20, 2022
e579655
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 20, 2022
564e16c
Update CHANGELOG.md
wsad1 Sep 20, 2022
48c0ca4
Update add_metapaths.py
wsad1 Sep 20, 2022
53b0b06
Update add_metapaths.py
wsad1 Sep 20, 2022
86328d4
Update add_metapaths.py
wsad1 Sep 20, 2022
d72c0cb
Update CHANGELOG.md
wsad1 Sep 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
coalesce edges
  • Loading branch information
EdisonLeeeee committed Sep 17, 2022
commit 97de0f5913495cba64ac025957e8daa2d9ceb3dd
6 changes: 3 additions & 3 deletions test/transforms/test_add_metapaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_add_random_metapaths():
assert meta3['metapath_0'].edge_index.size() == (2, 5)
assert meta4['metapath_0'].edge_index.size() == (2, 5)
assert meta5['metapath_0'].edge_index.size() == (2, 4)
assert meta6['metapath_0'].edge_index.size() == (2, 25)
assert meta6['metapath_0'].edge_index.size() == (2, 7)

assert all([i in meta1.edge_types for i in data.edge_types])
assert meta2.edge_types == [('p', 'metapath_0', 'p')]
Expand Down Expand Up @@ -227,5 +227,5 @@ def test_add_random_metapaths():

meta2 = transform(copy.copy(data))
new_edge_types = [('a', 'metapath_0', 'c'), ('a', 'metapath_1', 'a')]
assert meta2['metapath_0'].edge_index.size() == (2, 4)
assert meta2['metapath_1'].edge_index.size() == (2, 10)
assert meta2['metapath_0'].edge_index.size() == (2, 2)
assert meta2['metapath_1'].edge_index.size() == (2, 3)
4 changes: 2 additions & 2 deletions torch_geometric/transforms/add_metapaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from torch_geometric.data.datapipes import functional_transform
from torch_geometric.transforms import BaseTransform
from torch_geometric.typing import EdgeType
from torch_geometric.utils import degree
from torch_geometric.utils import coalesce, degree


@functional_transform('add_metapaths')
Expand Down Expand Up @@ -332,7 +332,7 @@ def __call__(self, data: HeteroData) -> HeteroData:
start = col

new_edge_type = (metapath[0][0], f'metapath_{j}', metapath[-1][-1])
data[new_edge_type].edge_index = torch.vstack([row, col])
data[new_edge_type].edge_index = coalesce(torch.vstack([row, col]))
data.metapath_dict[new_edge_type] = metapath

if self.drop_orig_edges:
Expand Down