Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
86d7cc97
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
86d7cc97
编写于
5月 22, 2018
作者:
W
whs
提交者:
GitHub
5月 22, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add bias for gru_unit_op and fix activation function (#10087)
上级
0d94ab13
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
15 addition
and
18 deletion
+15
-18
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+15
-18
未找到文件。
python/paddle/fluid/layers/nn.py
浏览文件 @
86d7cc97
...
@@ -699,8 +699,8 @@ def dynamic_gru(input,
...
@@ -699,8 +699,8 @@ def dynamic_gru(input,
def
gru_unit
(
input
,
def
gru_unit
(
input
,
hidden
,
hidden
,
size
,
size
,
weight
=
None
,
param_attr
=
None
,
bias
=
None
,
bias
_attr
=
None
,
activation
=
'tanh'
,
activation
=
'tanh'
,
gate_activation
=
'sigmoid'
):
gate_activation
=
'sigmoid'
):
"""
"""
...
@@ -731,8 +731,8 @@ def gru_unit(input,
...
@@ -731,8 +731,8 @@ def gru_unit(input,
input (Variable): The fc transformed input value of current step.
input (Variable): The fc transformed input value of current step.
hidden (Variable): The hidden value of lstm unit from previous step.
hidden (Variable): The hidden value of lstm unit from previous step.
size (integer): The input dimension value.
size (integer): The input dimension value.
weight
(ParamAttr): The weight parameters for gru unit. Default: None
param_attr
(ParamAttr): The weight parameters for gru unit. Default: None
bias (ParamAttr): The bias parameters for gru unit. Default: None
bias
_attr
(ParamAttr): The bias parameters for gru unit. Default: None
activation (string): The activation type for cell (actNode).
activation (string): The activation type for cell (actNode).
Default: 'tanh'
Default: 'tanh'
gate_activation (string): The activation type for gates (actGate).
gate_activation (string): The activation type for gates (actGate).
...
@@ -764,34 +764,31 @@ def gru_unit(input,
...
@@ -764,34 +764,31 @@ def gru_unit(input,
size
=
size
/
3
size
=
size
/
3
# create weight
# create weight
if
weight
is
None
:
weight
=
helper
.
create_parameter
(
weight
=
helper
.
create_parameter
(
attr
=
helper
.
param_attr
,
shape
=
[
size
,
3
*
size
],
dtype
=
dtype
)
attr
=
helper
.
param_attr
,
shape
=
[
size
,
3
*
size
],
dtype
=
dtype
)
gate
=
helper
.
create_tmp_variable
(
dtype
)
reset_hidden_pre
=
helper
.
create_tmp_variable
(
dtype
)
updated_hidden
=
helper
.
create_tmp_variable
(
dtype
)
inputs
=
{
'Input'
:
input
,
'HiddenPrev'
:
hidden
,
'Weight'
:
weight
}
# create bias
# create bias
if
helper
.
bias_attr
:
if
bias
is
None
:
bias_size
=
[
1
,
3
*
size
]
bias_size
=
[
1
,
3
*
size
]
bias
=
helper
.
create_parameter
(
bias
=
helper
.
create_parameter
(
attr
=
helper
.
bias_attr
,
shape
=
bias_size
,
dtype
=
dtype
,
is_bias
=
True
)
attr
=
helper
.
bias_attr
,
shape
=
bias_size
,
dtype
=
dtype
,
is_bias
=
True
)
inputs
[
'Bias'
]
=
bias
gate
=
helper
.
create_tmp_variable
(
dtype
)
reset_hidden_pre
=
helper
.
create_tmp_variable
(
dtype
)
updated_hidden
=
helper
.
create_tmp_variable
(
dtype
)
helper
.
append_op
(
helper
.
append_op
(
type
=
'gru_unit'
,
type
=
'gru_unit'
,
inputs
=
{
'Input'
:
input
,
inputs
=
inputs
,
'HiddenPrev'
:
hidden
,
'Weight'
:
weight
},
outputs
=
{
outputs
=
{
'Gate'
:
gate
,
'Gate'
:
gate
,
'ResetHiddenPrev'
:
reset_hidden_pre
,
'ResetHiddenPrev'
:
reset_hidden_pre
,
'Hidden'
:
updated_hidden
,
'Hidden'
:
updated_hidden
,
},
},
attrs
=
{
attrs
=
{
'activation'
:
0
,
'activation'
:
2
,
# tanh
'gate_activation'
:
1
,
'gate_activation'
:
1
,
# sigmoid
})
})
return
updated_hidden
,
reset_hidden_pre
,
gate
return
updated_hidden
,
reset_hidden_pre
,
gate
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录