Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
2c225525
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看板
提交
2c225525
编写于
3月 20, 2018
作者:
Y
yangyaming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix some comments and adapt test_machine_translation.py.
上级
2f2c5f5e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
5 addition
and
12 deletion
+5
-12
paddle/fluid/operators/sequence_expand_op.cc
paddle/fluid/operators/sequence_expand_op.cc
+2
-2
paddle/fluid/operators/sequence_expand_op.h
paddle/fluid/operators/sequence_expand_op.h
+0
-7
python/paddle/fluid/tests/book/test_machine_translation.py
python/paddle/fluid/tests/book/test_machine_translation.py
+3
-3
未找到文件。
paddle/fluid/operators/sequence_expand_op.cc
浏览文件 @
2c225525
...
...
@@ -145,7 +145,7 @@ and input(Y)
[0, 3, 6, 6, 8]]
ref_level: 0
then we get 1-level LoDTensor
Out.lod = [[0,
2,
5, 8]]
Out.lod = [[0,
1, 2,
5, 8]]
Out.data = [[a], [a], [b], [c], [d], [b], [c], [d]]
Out.dims = [8, 1]
...
...
@@ -157,7 +157,7 @@ Given a common Tensor input(X)
and input(Y)
Y.lod = [[0, 2, 3, 6]]
ref_level: -1
then we a common Tensor
then we
get
a common Tensor
Out.data = [[a], [a], [b], [c], [c], [c]]
Out.dims = [6, 1]
...
...
paddle/fluid/operators/sequence_expand_op.h
浏览文件 @
2c225525
...
...
@@ -37,13 +37,6 @@ class SequenceExpandKernel : public framework::OpKernel<T> {
int
ref_level
=
context
.
Attr
<
int
>
(
"ref_level"
);
auto
&
x_lod
=
x
->
lod
();
auto
&
y_lod
=
y
->
lod
();
PADDLE_ENFORCE_GT
(
y_lod
.
size
(),
0
,
"Level number of `Y`'s lod should be greater than 0."
);
PADDLE_ENFORCE
(
ref_level
==
-
1
||
(
ref_level
>=
0
&&
ref_level
<
y_lod
.
size
()),
"Invlid `ref_level`, which should be either equal to -1 "
"or in [0, %d)"
,
y_lod
.
size
());
if
(
ref_level
==
-
1
)
ref_level
=
y_lod
.
size
()
-
1
;
...
...
python/paddle/fluid/tests/book/test_machine_translation.py
浏览文件 @
2c225525
...
...
@@ -118,12 +118,12 @@ def decoder_decode(context, is_sparse):
is_sparse
=
is_sparse
)
# use rnn unit to update rnn
current_state
=
pd
.
fc
(
input
=
[
pre_
ids_emb
,
pre_state_expanded
],
current_state
=
pd
.
fc
(
input
=
[
pre_
state_expanded
,
pre_ids_emb
],
size
=
decoder_size
,
act
=
'tanh'
)
current_state_with_lod
=
pd
.
lod_reset
(
x
=
current_state
,
y
=
pre_score
)
# use score to do beam search
current_score
=
pd
.
fc
(
input
=
current_state
,
current_score
=
pd
.
fc
(
input
=
current_state
_with_lod
,
size
=
target_dict_dim
,
act
=
'softmax'
)
topk_scores
,
topk_indices
=
pd
.
topk
(
current_score
,
k
=
50
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录