Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
ba51e6ea
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ba51e6ea
编写于
4月 10, 2017
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix style problem
上级
d6e8d5cd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
16 addition
and
15 deletion
+16
-15
demo/seqToseq/seqToseq_net.py
demo/seqToseq/seqToseq_net.py
+3
-2
python/paddle/v2/config_base.py
python/paddle/v2/config_base.py
+2
-1
python/paddle/v2/layer.py
python/paddle/v2/layer.py
+3
-4
python/paddle/v2/layers/__init__.py
python/paddle/v2/layers/__init__.py
+1
-1
python/paddle/v2/layers/beam_search.py
python/paddle/v2/layers/beam_search.py
+7
-7
未找到文件。
demo/seqToseq/seqToseq_net.py
浏览文件 @
ba51e6ea
...
...
@@ -131,8 +131,9 @@ def gru_encoder_decoder(data_conf,
decoder_group_name
=
"decoder_group"
group_inputs
=
[
StaticInput
(
input
=
encoded_vector
,
is_seq
=
True
),
StaticInput
(
input
=
encoded_proj
,
is_seq
=
True
)
StaticInput
(
input
=
encoded_vector
,
is_seq
=
True
),
StaticInput
(
input
=
encoded_proj
,
is_seq
=
True
)
]
if
not
is_generating
:
...
...
python/paddle/v2/config_base.py
浏览文件 @
ba51e6ea
...
...
@@ -114,7 +114,8 @@ class Layer(object):
# 4. parse myself and add myself into context.
ret_val
=
self
.
to_proto_impl
(
context
=
context
,
**
kwargs
)
if
self
.
context_name
()
is
not
None
and
self
.
context_name
()
not
in
context
:
if
self
.
context_name
()
is
not
None
and
self
.
context_name
(
)
not
in
context
:
context
[
self
.
context_name
()]
=
ret_val
# 5. parse children that should be pased after this layer.
...
...
python/paddle/v2/layer.py
浏览文件 @
ba51e6ea
...
...
@@ -292,7 +292,8 @@ class RecurrentLayerInput(Layer):
else
:
self
.
__parents__
=
parent_layers
.
values
()[
0
]
self
.
__recurrent_name__
=
recurrent_name
name
=
self
.
__parents__
[
index
].
name
if
index
>=
0
else
self
.
context_name
()
name
=
self
.
__parents__
[
index
].
name
if
index
>=
0
else
self
.
context_name
()
super
(
RecurrentLayerInput
,
self
).
__init__
(
name
=
name
,
parent_layers
=
parent_layers
)
...
...
@@ -402,9 +403,7 @@ def recurrent_group(step, input, name=None):
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
=
{})
def
__real_step__
(
*
args
):
rnn_input
=
list
(
args
)
...
...
python/paddle/v2/layers/__init__.py
浏览文件 @
ba51e6ea
import
beam_search
\ No newline at end of file
import
beam_search
python/paddle/v2/layers/beam_search.py
浏览文件 @
ba51e6ea
...
...
@@ -63,6 +63,7 @@ class RecurrentLayerGroupSetGeneratorV2(Layer):
def
use_context_name
(
self
):
return
True
@
wrap_name_default
()
def
beam_search
(
step
,
input
,
...
...
@@ -75,9 +76,10 @@ def beam_search(step,
if
num_results_per_sample
is
None
:
num_results_per_sample
=
beam_size
assert
num_results_per_sample
<=
beam_size
# logger.warning("num_results_per_sample should be less than beam_size")
# logger.warning("num_results_per_sample should be less than beam_size")
if
isinstance
(
input
,
paddle
.
layer
.
StaticInputV2
)
or
isinstance
(
input
,
BaseGeneratedInputV2
):
if
isinstance
(
input
,
paddle
.
layer
.
StaticInputV2
)
or
isinstance
(
input
,
BaseGeneratedInputV2
):
input
=
[
input
]
generated_input_index
=
-
1
...
...
@@ -107,8 +109,8 @@ def beam_search(step,
args
=
list
(
args
)
before_step_layer
=
gipt
.
before_real_step
()
before_step_layer
.
append_child
(
layer
=
generator
,
parent_names
=
[
before_step_layer
.
name
])
before_step_layer
.
append_child
(
layer
=
generator
,
parent_names
=
[
before_step_layer
.
name
])
args
.
insert
(
generated_input_index
,
before_step_layer
)
predict
=
gipt
.
after_real_step
(
step
(
*
args
))
...
...
@@ -125,8 +127,6 @@ def beam_search(step,
# name=name,
# is_generating=True)
tmp
=
paddle
.
layer
.
recurrent_group
(
step
=
__real_step__
,
input
=
real_input
,
name
=
name
)
step
=
__real_step__
,
input
=
real_input
,
name
=
name
)
return
tmp
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录