Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
9e39359b
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看板
提交
9e39359b
编写于
7月 16, 2018
作者:
G
guosheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make train.py support en-fr wordpiece data in Transformer
上级
88142779
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
3 deletion
+26
-3
fluid/neural_machine_translation/transformer/infer.py
fluid/neural_machine_translation/transformer/infer.py
+11
-3
fluid/neural_machine_translation/transformer/train.py
fluid/neural_machine_translation/transformer/train.py
+15
-0
未找到文件。
fluid/neural_machine_translation/transformer/infer.py
浏览文件 @
9e39359b
...
...
@@ -52,10 +52,17 @@ def parse_args():
"--use_wordpiece"
,
type
=
ast
.
literal_eval
,
default
=
False
,
help
=
"The flag indicating if the data is wordpiece data. The EN-FR data
we
"
"provided is wordpiece data. For wordpiece data, converting ids to "
help
=
"The flag indicating if the data is wordpiece data. The EN-FR data "
"
we
provided is wordpiece data. For wordpiece data, converting ids to "
"original words is a little different and some special codes are "
"provided in util.py to do this."
)
parser
.
add_argument
(
"--token_delimiter"
,
type
=
str
,
default
=
" "
,
help
=
"The delimiter used to split tokens in source or target sentences. "
"For EN-DE BPE data we provided, use spaces as token delimiter.; "
"For EN-FR wordpiece data we provided, use '
\x01
' as token delimiter."
)
parser
.
add_argument
(
'opts'
,
help
=
'See config.py for all options'
,
...
...
@@ -549,8 +556,9 @@ def infer(args, inferencer=fast_infer):
src_vocab_fpath
=
args
.
src_vocab_fpath
,
trg_vocab_fpath
=
args
.
trg_vocab_fpath
,
fpattern
=
args
.
test_file_pattern
,
batch_size
=
args
.
batch_size
,
token_delimiter
=
args
.
token_delimiter
,
use_token_batch
=
False
,
batch_size
=
args
.
batch_size
,
pool_size
=
args
.
pool_size
,
sort_type
=
reader
.
SortType
.
NONE
,
shuffle
=
False
,
...
...
fluid/neural_machine_translation/transformer/train.py
浏览文件 @
9e39359b
...
...
@@ -76,6 +76,19 @@ def parse_args():
default
=
[
"<s>"
,
"<e>"
,
"<unk>"
],
nargs
=
3
,
help
=
"The <bos>, <eos> and <unk> tokens in the dictionary."
)
parser
.
add_argument
(
"--use_wordpiece"
,
type
=
ast
.
literal_eval
,
default
=
False
,
help
=
"The flag indicating if the data is wordpiece data. The EN-FR "
"data we provided is wordpiece data."
)
parser
.
add_argument
(
"--token_delimiter"
,
type
=
str
,
default
=
" "
,
help
=
"The delimiter used to split tokens in source or target sentences. "
"For EN-DE BPE data we provided, use spaces as token delimiter.; "
"For EN-FR wordpiece data we provided, use '
\x01
' as token delimiter."
)
parser
.
add_argument
(
'opts'
,
help
=
'See config.py for all options'
,
...
...
@@ -273,6 +286,7 @@ def test_context(train_progm, avg_cost, train_exe, dev_count, data_input_names,
src_vocab_fpath
=
args
.
src_vocab_fpath
,
trg_vocab_fpath
=
args
.
trg_vocab_fpath
,
fpattern
=
args
.
val_file_pattern
,
token_delimiter
=
args
.
token_delimiter
,
use_token_batch
=
args
.
use_token_batch
,
batch_size
=
args
.
batch_size
*
(
1
if
args
.
use_token_batch
else
dev_count
),
pool_size
=
args
.
pool_size
,
...
...
@@ -335,6 +349,7 @@ def train_loop(exe, train_progm, dev_count, sum_cost, avg_cost, lr_scheduler,
src_vocab_fpath
=
args
.
src_vocab_fpath
,
trg_vocab_fpath
=
args
.
trg_vocab_fpath
,
fpattern
=
args
.
train_file_pattern
,
token_delimiter
=
args
.
token_delimiter
,
use_token_batch
=
args
.
use_token_batch
,
batch_size
=
args
.
batch_size
*
(
1
if
args
.
use_token_batch
else
dev_count
),
pool_size
=
args
.
pool_size
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录