Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
1214fdfd
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1214fdfd
编写于
7月 17, 2019
作者:
G
guoshengCS
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix inference output encoding in Transformer under python3 and windows.
上级
f3c92f11
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
4 deletion
+17
-4
PaddleNLP/neural_machine_translation/transformer/infer.py
PaddleNLP/neural_machine_translation/transformer/infer.py
+5
-2
PaddleNLP/neural_machine_translation/transformer/train.py
PaddleNLP/neural_machine_translation/transformer/train.py
+3
-0
PaddleNLP/unarchived/neural_machine_translation/transformer/infer.py
...narchived/neural_machine_translation/transformer/infer.py
+6
-2
PaddleNLP/unarchived/neural_machine_translation/transformer/train.py
...narchived/neural_machine_translation/transformer/train.py
+3
-0
未找到文件。
PaddleNLP/neural_machine_translation/transformer/infer.py
浏览文件 @
1214fdfd
...
@@ -4,6 +4,9 @@ import multiprocessing
...
@@ -4,6 +4,9 @@ import multiprocessing
import
numpy
as
np
import
numpy
as
np
import
os
import
os
import
sys
import
sys
if
sys
.
version
[
0
]
==
'2'
:
reload
(
sys
)
sys
.
setdefaultencoding
(
"utf-8"
)
sys
.
path
.
append
(
"../../"
)
sys
.
path
.
append
(
"../../"
)
sys
.
path
.
append
(
"../../models/neural_machine_translation/transformer/"
)
sys
.
path
.
append
(
"../../models/neural_machine_translation/transformer/"
)
from
functools
import
partial
from
functools
import
partial
...
@@ -307,13 +310,13 @@ def fast_infer(args):
...
@@ -307,13 +310,13 @@ def fast_infer(args):
for
j
in
range
(
end
-
start
):
# for each candidate
for
j
in
range
(
end
-
start
):
# for each candidate
sub_start
=
seq_ids
.
lod
()[
1
][
start
+
j
]
sub_start
=
seq_ids
.
lod
()[
1
][
start
+
j
]
sub_end
=
seq_ids
.
lod
()[
1
][
start
+
j
+
1
]
sub_end
=
seq_ids
.
lod
()[
1
][
start
+
j
+
1
]
hyps
[
i
].
append
(
" "
.
join
([
hyps
[
i
].
append
(
b
" "
.
join
([
trg_idx2word
[
idx
]
trg_idx2word
[
idx
]
for
idx
in
post_process_seq
(
for
idx
in
post_process_seq
(
np
.
array
(
seq_ids
)[
sub_start
:
sub_end
])
np
.
array
(
seq_ids
)[
sub_start
:
sub_end
])
]))
]))
scores
[
i
].
append
(
np
.
array
(
seq_scores
)[
sub_end
-
1
])
scores
[
i
].
append
(
np
.
array
(
seq_scores
)[
sub_end
-
1
])
print
(
hyps
[
i
][
-
1
])
print
(
hyps
[
i
][
-
1
]
.
decode
(
"utf8"
)
)
if
len
(
hyps
[
i
])
>=
InferTaskConfig
.
n_best
:
if
len
(
hyps
[
i
])
>=
InferTaskConfig
.
n_best
:
break
break
except
(
StopIteration
,
fluid
.
core
.
EOFException
):
except
(
StopIteration
,
fluid
.
core
.
EOFException
):
...
...
PaddleNLP/neural_machine_translation/transformer/train.py
浏览文件 @
1214fdfd
...
@@ -11,6 +11,9 @@ if os.environ.get('FLAGS_eager_delete_tensor_gb', None) is None:
...
@@ -11,6 +11,9 @@ if os.environ.get('FLAGS_eager_delete_tensor_gb', None) is None:
import
six
import
six
import
sys
import
sys
if
sys
.
version
[
0
]
==
'2'
:
reload
(
sys
)
sys
.
setdefaultencoding
(
"utf-8"
)
sys
.
path
.
append
(
"../../"
)
sys
.
path
.
append
(
"../../"
)
sys
.
path
.
append
(
"../../models/neural_machine_translation/transformer/"
)
sys
.
path
.
append
(
"../../models/neural_machine_translation/transformer/"
)
import
time
import
time
...
...
PaddleNLP/unarchived/neural_machine_translation/transformer/infer.py
浏览文件 @
1214fdfd
...
@@ -3,6 +3,10 @@ import ast
...
@@ -3,6 +3,10 @@ import ast
import
multiprocessing
import
multiprocessing
import
numpy
as
np
import
numpy
as
np
import
os
import
os
import
sys
if
sys
.
version
[
0
]
==
'2'
:
reload
(
sys
)
sys
.
setdefaultencoding
(
"utf-8"
)
from
functools
import
partial
from
functools
import
partial
import
paddle
import
paddle
...
@@ -303,13 +307,13 @@ def fast_infer(args):
...
@@ -303,13 +307,13 @@ def fast_infer(args):
for
j
in
range
(
end
-
start
):
# for each candidate
for
j
in
range
(
end
-
start
):
# for each candidate
sub_start
=
seq_ids
.
lod
()[
1
][
start
+
j
]
sub_start
=
seq_ids
.
lod
()[
1
][
start
+
j
]
sub_end
=
seq_ids
.
lod
()[
1
][
start
+
j
+
1
]
sub_end
=
seq_ids
.
lod
()[
1
][
start
+
j
+
1
]
hyps
[
i
].
append
(
" "
.
join
([
hyps
[
i
].
append
(
b
" "
.
join
([
trg_idx2word
[
idx
]
trg_idx2word
[
idx
]
for
idx
in
post_process_seq
(
for
idx
in
post_process_seq
(
np
.
array
(
seq_ids
)[
sub_start
:
sub_end
])
np
.
array
(
seq_ids
)[
sub_start
:
sub_end
])
]))
]))
scores
[
i
].
append
(
np
.
array
(
seq_scores
)[
sub_end
-
1
])
scores
[
i
].
append
(
np
.
array
(
seq_scores
)[
sub_end
-
1
])
print
(
hyps
[
i
][
-
1
])
print
(
hyps
[
i
][
-
1
]
.
decode
(
"utf8"
)
)
if
len
(
hyps
[
i
])
>=
InferTaskConfig
.
n_best
:
if
len
(
hyps
[
i
])
>=
InferTaskConfig
.
n_best
:
break
break
except
(
StopIteration
,
fluid
.
core
.
EOFException
):
except
(
StopIteration
,
fluid
.
core
.
EOFException
):
...
...
PaddleNLP/unarchived/neural_machine_translation/transformer/train.py
浏览文件 @
1214fdfd
...
@@ -6,6 +6,9 @@ import multiprocessing
...
@@ -6,6 +6,9 @@ import multiprocessing
import
os
import
os
import
six
import
six
import
sys
import
sys
if
sys
.
version
[
0
]
==
'2'
:
reload
(
sys
)
sys
.
setdefaultencoding
(
"utf-8"
)
import
time
import
time
import
numpy
as
np
import
numpy
as
np
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录