Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PGL
提交
84b9d61c
P
PGL
项目概览
PaddlePaddle
/
PGL
通知
76
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
11
列表
看板
标记
里程碑
合并请求
1
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PGL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
11
Issue
11
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
84b9d61c
编写于
7月 01, 2020
作者:
Z
Zhong Hui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine graph saint
上级
a43b5a2e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
10 deletion
+15
-10
ogb_examples/nodeproppred/ogbn-arxiv/dataloader/ogbn_arxiv_dataloader.py
...deproppred/ogbn-arxiv/dataloader/ogbn_arxiv_dataloader.py
+5
-5
pgl/graph_kernel.pyx
pgl/graph_kernel.pyx
+1
-1
pgl/sample.py
pgl/sample.py
+9
-4
未找到文件。
ogb_examples/nodeproppred/ogbn-arxiv/dataloader/ogbn_arxiv_dataloader.py
浏览文件 @
84b9d61c
...
...
@@ -24,7 +24,7 @@ import ssl
ssl
.
_create_default_https_context
=
ssl
.
_create_unverified_context
from
pgl.contrib.ogb.nodeproppred.dataset_pgl
import
PglNodePropPredDataset
#
from pgl.sample import graph_saint_random_walk_sample
from
pgl.sample
import
graph_saint_random_walk_sample
from
ogb.nodeproppred
import
Evaluator
import
tqdm
from
collections
import
namedtuple
...
...
@@ -78,10 +78,10 @@ def k_hop_sampler(graph, samples, batch_nodes):
return
subgraph
,
sub_node_index
#
def graph_saint_randomwalk_sampler(graph, batch_nodes, max_depth=3):
#
subgraph = graph_saint_random_walk_sample(graph, batch_nodes, max_depth)
#
sub_node_index = subgraph.reindex_from_parrent_nodes(batch_nodes)
#
return subgraph, sub_node_index
def
graph_saint_randomwalk_sampler
(
graph
,
batch_nodes
,
max_depth
=
3
):
subgraph
=
graph_saint_random_walk_sample
(
graph
,
batch_nodes
,
max_depth
)
sub_node_index
=
subgraph
.
reindex_from_parrent_nodes
(
batch_nodes
)
return
subgraph
,
sub_node_index
class
ArxivDataGenerator
(
BaseDataGenerator
):
...
...
pgl/graph_kernel.pyx
浏览文件 @
84b9d61c
...
...
@@ -325,7 +325,7 @@ def alias_sample_build_table(np.ndarray[np.float64_t, ndim=1] probs):
@
cython
.
boundscheck
(
False
)
@
cython
.
wraparound
(
False
)
def
adj_extract
(
def
extract_edges_from_nodes
(
np
.
ndarray
[
np
.
int64_t
,
ndim
=
1
]
adj_indptr
,
np
.
ndarray
[
np
.
int64_t
,
ndim
=
1
]
sorted_v
,
vector
[
long
long
]
sampled_nodes
,
...
...
pgl/sample.py
浏览文件 @
84b9d61c
...
...
@@ -24,7 +24,7 @@ from pgl import graph_kernel
__all__
=
[
'graphsage_sample'
,
'node2vec_sample'
,
'deepwalk_sample'
,
'metapath_randomwalk'
,
'pinsage_sample'
'metapath_randomwalk'
,
'pinsage_sample'
,
'graph_saint_random_walk_sample'
]
...
...
@@ -478,6 +478,13 @@ def pinsage_sample(graph,
return
subgraphs
def
extract_edges_from_nodes
(
graph
,
sample_nodes
):
eids
=
graph_kernel
.
extract_edges_from_nodes
(
graph
.
_adj_dst_index
.
_indptr
,
graph
.
_adj_dst_index
.
_sorted_v
,
sample_nodes
)
return
eids
def
graph_saint_random_walk_sample
(
graph
,
nodes
,
max_depth
,
...
...
@@ -504,9 +511,7 @@ def graph_saint_random_walk_sample(graph,
for
walk
in
walks
:
sample_nodes
.
extend
(
walk
)
sample_nodes
=
np
.
unique
(
sample_nodes
)
eids
=
graph_kernel
.
adj_extract
(
graph
.
_adj_dst_index
.
_indptr
,
graph
.
_adj_dst_index
.
_sorted_v
,
sample_nodes
)
eids
=
extract_edges_from_nodes
(
graph
,
sample_nodes
)
subgraph
=
graph
.
subgraph
(
nodes
=
sample_nodes
,
eid
=
eids
,
with_node_feat
=
True
,
with_edge_feat
=
True
)
subgraph
.
node_feat
[
"index"
]
=
np
.
array
(
sample_nodes
,
dtype
=
"int64"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录