Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PGL
提交
8246974a
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看板
提交
8246974a
编写于
4月 08, 2020
作者:
W
Webbley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add gin layer
上级
89885a8c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
1 deletion
+50
-1
pgl/layers/conv.py
pgl/layers/conv.py
+50
-1
未找到文件。
pgl/layers/conv.py
浏览文件 @
8246974a
...
...
@@ -18,7 +18,7 @@ import paddle.fluid as fluid
from
pgl
import
graph_wrapper
from
pgl.utils
import
paddle_helper
__all__
=
[
'gcn'
,
'gat'
]
__all__
=
[
'gcn'
,
'gat'
,
'gin'
]
def
gcn
(
gw
,
feature
,
hidden_size
,
activation
,
name
,
norm
=
None
):
...
...
@@ -178,3 +178,52 @@ def gat(gw,
bias
.
stop_gradient
=
True
output
=
fluid
.
layers
.
elementwise_add
(
output
,
bias
,
act
=
activation
)
return
output
def
gin
(
gw
,
feature
,
name
,
init_eps
=
0.0
,
train_eps
=
False
,
apply_func
=
None
):
"""Implementation of Graph Isomorphism Network (GIN) layer.
This is an implementation of the paper How Powerful are Graph Neural Networks?
(https://arxiv.org/pdf/1810.00826.pdf).
Args:
gw: Graph wrapper object (:code:`StaticGraphWrapper` or :code:`GraphWrapper`)
feature: A tensor with shape (num_nodes, feature_size).
name: GIN layer names.
init_eps: float, optional
Initial :math:`\epsilon` value, default is 0.
train_eps: bool, optional
if True, :math:`\epsilon` will be a learnable parameter.
apply_func: Callable activation function or None.
Default is None. If not None, apply this function to the updated feature.
Return:
A tensor with shape (num_nodes, output_size) where ``output_size`` is the
output dimensionality of ``apply_func``. If ``apply_func`` is None, ``output_size``
should be the same as ``feature_size``.
"""
def
send_src_copy
(
src_feat
,
dst_feat
,
edge_feat
):
return
src_feat
[
"h"
]
epsilon
=
fluid
.
layers
.
create_parameter
(
shape
=
[
1
,
1
],
dtype
=
"float32"
,
attr
=
F
.
ParamAttr
(
name
=
"%s_eps"
%
name
),
default_initializer
=
F
.
initializer
.
ConstantInitializer
(
value
=
init_eps
))
if
not
train_eps
:
epsilon
.
stop_gradient
=
True
msg
=
gw
.
send
(
send_src_copy
,
nfeat_list
=
[(
"h"
,
feature
)])
output
=
gw
.
recv
(
msg
,
"sum"
)
+
(
1.0
+
epsilon
)
*
feature
if
apply_func
is
not
None
:
output
=
apply_func
(
output
,
name
)
return
output
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录