Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
f8e03bf6
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看板
提交
f8e03bf6
编写于
7月 02, 2018
作者:
G
guosheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the max length in Transformer to count start and end tokens in
上级
8222284e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
8 addition
and
7 deletion
+8
-7
fluid/neural_machine_translation/transformer/config.py
fluid/neural_machine_translation/transformer/config.py
+2
-4
fluid/neural_machine_translation/transformer/infer.py
fluid/neural_machine_translation/transformer/infer.py
+2
-1
fluid/neural_machine_translation/transformer/train.py
fluid/neural_machine_translation/transformer/train.py
+4
-2
未找到文件。
fluid/neural_machine_translation/transformer/config.py
浏览文件 @
f8e03bf6
...
@@ -62,10 +62,8 @@ class ModelHyperParams(object):
...
@@ -62,10 +62,8 @@ class ModelHyperParams(object):
eos_idx
=
1
eos_idx
=
1
# index for <unk> token
# index for <unk> token
unk_idx
=
2
unk_idx
=
2
# max length of sequences.
# max length of sequences deciding the size of position encoding table.
# The size of position encoding table should at least plus 1, since the
# Start from 1 and count start and end tokens in.
# sinusoid position encoding starts from 1 and 0 can be used as the padding
# token for position encoding.
max_length
=
256
max_length
=
256
# the dimension for word embeddings, which is also the last dimension of
# the dimension for word embeddings, which is also the last dimension of
# the input and output of multi-head attention, position-wise feed-forward
# the input and output of multi-head attention, position-wise feed-forward
...
...
fluid/neural_machine_translation/transformer/infer.py
浏览文件 @
f8e03bf6
...
@@ -543,7 +543,8 @@ def infer(args, inferencer=fast_infer):
...
@@ -543,7 +543,8 @@ def infer(args, inferencer=fast_infer):
start_mark
=
args
.
special_token
[
0
],
start_mark
=
args
.
special_token
[
0
],
end_mark
=
args
.
special_token
[
1
],
end_mark
=
args
.
special_token
[
1
],
unk_mark
=
args
.
special_token
[
2
],
unk_mark
=
args
.
special_token
[
2
],
max_length
=
ModelHyperParams
.
max_length
,
# count start and end tokens out
max_length
=
ModelHyperParams
.
max_length
-
2
,
clip_last_batch
=
False
)
clip_last_batch
=
False
)
trg_idx2word
=
test_data
.
load_dict
(
trg_idx2word
=
test_data
.
load_dict
(
dict_path
=
args
.
trg_vocab_fpath
,
reverse
=
True
)
dict_path
=
args
.
trg_vocab_fpath
,
reverse
=
True
)
...
...
fluid/neural_machine_translation/transformer/train.py
浏览文件 @
f8e03bf6
...
@@ -290,7 +290,8 @@ def train(args):
...
@@ -290,7 +290,8 @@ def train(args):
start_mark
=
args
.
special_token
[
0
],
start_mark
=
args
.
special_token
[
0
],
end_mark
=
args
.
special_token
[
1
],
end_mark
=
args
.
special_token
[
1
],
unk_mark
=
args
.
special_token
[
2
],
unk_mark
=
args
.
special_token
[
2
],
max_length
=
ModelHyperParams
.
max_length
,
# count start and end tokens out
max_length
=
ModelHyperParams
.
max_length
-
2
,
clip_last_batch
=
False
)
clip_last_batch
=
False
)
train_data
=
read_multiple
(
train_data
=
read_multiple
(
reader
=
train_data
.
batch_generator
,
reader
=
train_data
.
batch_generator
,
...
@@ -326,7 +327,8 @@ def train(args):
...
@@ -326,7 +327,8 @@ def train(args):
start_mark
=
args
.
special_token
[
0
],
start_mark
=
args
.
special_token
[
0
],
end_mark
=
args
.
special_token
[
1
],
end_mark
=
args
.
special_token
[
1
],
unk_mark
=
args
.
special_token
[
2
],
unk_mark
=
args
.
special_token
[
2
],
max_length
=
ModelHyperParams
.
max_length
,
# count start and end tokens out
max_length
=
ModelHyperParams
.
max_length
-
2
,
clip_last_batch
=
False
,
clip_last_batch
=
False
,
shuffle
=
False
,
shuffle
=
False
,
shuffle_batch
=
False
)
shuffle_batch
=
False
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录