Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
0ee31a03
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0ee31a03
编写于
5月 25, 2017
作者:
L
Luo Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Expose the "reverse" argument for recurrent_group in V2 API
上级
21be601b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
11 addition
and
8 deletion
+11
-8
python/paddle/v2/layer.py
python/paddle/v2/layer.py
+8
-6
python/paddle/v2/tests/test_rnn_layer.py
python/paddle/v2/tests/test_rnn_layer.py
+3
-2
未找到文件。
python/paddle/v2/layer.py
浏览文件 @
0ee31a03
...
...
@@ -360,7 +360,7 @@ mixed.__doc__ = conf_helps.mixed_layer.__doc__
class
RecurrentLayerInput
(
Layer
):
def
__init__
(
self
,
recurrent_name
,
index
,
parent_layers
):
def
__init__
(
self
,
recurrent_name
,
index
,
parent_layers
,
reverse
):
parents_len
=
len
(
parent_layers
)
assert
parents_len
<=
1
if
parents_len
==
0
:
...
...
@@ -368,6 +368,7 @@ class RecurrentLayerInput(Layer):
else
:
self
.
__parents__
=
parent_layers
.
values
()[
0
]
self
.
__recurrent_name__
=
recurrent_name
self
.
__reverse__
=
reverse
name
=
self
.
__parents__
[
index
].
name
if
index
>=
0
else
self
.
context_name
()
super
(
RecurrentLayerInput
,
self
).
__init__
(
...
...
@@ -380,7 +381,8 @@ class RecurrentLayerInput(Layer):
model_type
(
'recurrent_nn'
)
RecurrentLayerGroupWithoutOutLinksBegin
(
name
=
self
.
__recurrent_name__
,
in_links
=
map
(
lambda
x
:
x
.
name
,
self
.
__parents__
))
in_links
=
map
(
lambda
x
:
x
.
name
,
self
.
__parents__
),
seq_reversed
=
self
.
__reverse__
)
return
self
...
...
@@ -461,7 +463,7 @@ del each_layer_name
@
wrap_name_default
()
def
recurrent_group
(
step
,
input
,
name
=
None
):
def
recurrent_group
(
step
,
input
,
reverse
=
False
,
name
=
None
):
if
not
isinstance
(
input
,
collections
.
Sequence
):
input
=
[
input
]
...
...
@@ -471,14 +473,14 @@ def recurrent_group(step, input, name=None):
RecurrentLayerInput
(
recurrent_name
=
name
,
index
=
i
,
parent_layers
=
{
'recurrent_inputs'
:
non_static_inputs
}
)
for
i
in
xrange
(
len
(
non_static_inputs
))
parent_layers
=
{
'recurrent_inputs'
:
non_static_inputs
}
,
reverse
=
reverse
)
for
i
in
xrange
(
len
(
non_static_inputs
))
]
extra_input
=
None
if
len
(
non_static_inputs
)
==
0
:
extra_input
=
RecurrentLayerInput
(
recurrent_name
=
name
,
index
=-
1
,
parent_layers
=
{})
recurrent_name
=
name
,
index
=-
1
,
parent_layers
=
{}
,
reverse
=
reverse
)
def
__real_step__
(
*
args
):
rnn_input
=
list
(
args
)
...
...
python/paddle/v2/tests/test_rnn_layer.py
浏览文件 @
0ee31a03
...
...
@@ -42,7 +42,8 @@ class RNNTest(unittest.TestCase):
def
test
():
data
=
conf_helps
.
data_layer
(
name
=
"word"
,
size
=
dict_dim
)
embd
=
conf_helps
.
embedding_layer
(
input
=
data
,
size
=
word_dim
)
conf_helps
.
recurrent_group
(
name
=
"rnn"
,
step
=
step
,
input
=
embd
)
conf_helps
.
recurrent_group
(
name
=
"rnn"
,
step
=
step
,
input
=
embd
,
reverse
=
True
)
return
str
(
parse_network
(
test
))
...
...
@@ -60,7 +61,7 @@ class RNNTest(unittest.TestCase):
name
=
"word"
,
type
=
data_type
.
integer_value
(
dict_dim
))
embd
=
layer
.
embedding
(
input
=
data
,
size
=
word_dim
)
rnn_layer
=
layer
.
recurrent_group
(
name
=
"rnn"
,
step
=
new_step
,
input
=
embd
)
name
=
"rnn"
,
step
=
new_step
,
input
=
embd
,
reverse
=
True
)
return
str
(
layer
.
parse_network
(
rnn_layer
))
diff
=
difflib
.
unified_diff
(
parse_old_rnn
().
splitlines
(
1
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录