Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
49ca424d
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看板
提交
49ca424d
编写于
6月 14, 2018
作者:
G
guosheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix src_idx out of range in beam_search_op
上级
6e38cc33
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
11 addition
and
3 deletion
+11
-3
paddle/fluid/operators/beam_search_op.cc
paddle/fluid/operators/beam_search_op.cc
+1
-1
python/paddle/fluid/tests/book/high-level-api/machine_translation/test_machine_translation.py
...level-api/machine_translation/test_machine_translation.py
+5
-1
python/paddle/fluid/tests/book/test_machine_translation.py
python/paddle/fluid/tests/book/test_machine_translation.py
+5
-1
未找到文件。
paddle/fluid/operators/beam_search_op.cc
浏览文件 @
49ca424d
...
...
@@ -87,7 +87,7 @@ void BeamSearch::PruneEndBeams(const framework::LoDTensor &pre_ids,
auto
*
pre_ids_data
=
pre_ids
.
data
<
int64_t
>
();
auto
abs_lod
=
framework
::
ToAbsOffset
(
ids_
->
lod
());
auto
&
high_level
=
abs_lod
[
lod_level_
];
for
(
size_t
src_idx
=
0
;
src_idx
<
high_level
.
size
();
++
src_idx
)
{
for
(
size_t
src_idx
=
0
;
src_idx
<
high_level
.
size
()
-
1
;
++
src_idx
)
{
size_t
src_prefix_start
=
high_level
[
src_idx
];
size_t
src_prefix_end
=
high_level
[
src_idx
+
1
];
bool
finish_flag
=
true
;
...
...
python/paddle/fluid/tests/book/high-level-api/machine_translation/test_machine_translation.py
浏览文件 @
49ca424d
...
...
@@ -148,7 +148,11 @@ def decode(context, is_sparse):
pd
.
array_write
(
selected_ids
,
array
=
ids_array
,
i
=
counter
)
pd
.
array_write
(
selected_scores
,
array
=
scores_array
,
i
=
counter
)
pd
.
less_than
(
x
=
counter
,
y
=
array_len
,
cond
=
cond
)
# update the break condition: up to the max length or all candidates of
# source sentences have ended.
length_cond
=
pd
.
less_than
(
x
=
counter
,
y
=
array_len
)
finish_cond
=
pd
.
logical_not
(
pd
.
is_empty
(
x
=
selected_ids
))
pd
.
logical_and
(
x
=
length_cond
,
y
=
finish_cond
,
out
=
cond
)
translation_ids
,
translation_scores
=
pd
.
beam_search_decode
(
ids
=
ids_array
,
scores
=
scores_array
,
beam_size
=
beam_size
,
end_id
=
10
)
...
...
python/paddle/fluid/tests/book/test_machine_translation.py
浏览文件 @
49ca424d
...
...
@@ -147,7 +147,11 @@ def decoder_decode(context, is_sparse):
pd
.
array_write
(
selected_ids
,
array
=
ids_array
,
i
=
counter
)
pd
.
array_write
(
selected_scores
,
array
=
scores_array
,
i
=
counter
)
pd
.
less_than
(
x
=
counter
,
y
=
array_len
,
cond
=
cond
)
# update the break condition: up to the max length or all candidates of
# source sentences have ended.
length_cond
=
pd
.
less_than
(
x
=
counter
,
y
=
array_len
)
finish_cond
=
pd
.
logical_not
(
pd
.
is_empty
(
x
=
selected_ids
))
pd
.
logical_and
(
x
=
length_cond
,
y
=
finish_cond
,
out
=
cond
)
translation_ids
,
translation_scores
=
pd
.
beam_search_decode
(
ids
=
ids_array
,
scores
=
scores_array
,
beam_size
=
beam_size
,
end_id
=
10
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录