Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
b34e8c0e
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看板
提交
b34e8c0e
编写于
4月 10, 2018
作者:
G
guosheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Skip the part batches in Transformer when training
上级
91a0b7c6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
6 deletion
+13
-6
fluid/neural_machine_translation/transformer/config.py
fluid/neural_machine_translation/transformer/config.py
+7
-6
fluid/neural_machine_translation/transformer/model.py
fluid/neural_machine_translation/transformer/model.py
+4
-0
fluid/neural_machine_translation/transformer/train.py
fluid/neural_machine_translation/transformer/train.py
+2
-0
未找到文件。
fluid/neural_machine_translation/transformer/config.py
浏览文件 @
b34e8c0e
...
...
@@ -43,9 +43,10 @@ class InferTaskConfig(object):
class
ModelHyperParams
(
object
):
# Dictionary size for source and target language. This model directly uses
# paddle.dataset.wmt16 in which <bos>, <eos> and <unk> token has
# alreay been added.
# This model directly uses paddle.dataset.wmt16 in which <bos>, <eos> and
# <unk> token has alreay been added. As for the <pad> token, any token
# included in dict can be used to pad, since the paddings' loss will be
# masked out and make no effect on parameter gradients.
# size of source word dictionary.
src_vocab_size
=
10000
...
...
@@ -61,9 +62,9 @@ class ModelHyperParams(object):
unk_idx
=
2
# max length of sequences.
# The size of position encoding table should
plus 1, since the sinusoid
#
position encoding start from 1 and 0 can be used as the padding token
# for position encoding.
# The size of position encoding table should
at least plus 1, since the
#
sinusoid position encoding starts from 1 and 0 can be used as the padding
#
token
for position encoding.
max_length
=
50
# the dimension for word embeddings, which is also the last dimension of
...
...
fluid/neural_machine_translation/transformer/model.py
浏览文件 @
b34e8c0e
...
...
@@ -476,12 +476,16 @@ def make_inputs(input_data_names,
append_batch_size
=
False
)
input_layers
+=
[
slf_attn_post_softmax_shape
]
if
src_attn_shape_flag
:
# This shape input is used to reshape before softmax in encoder-decoder
# attention.
src_attn_pre_softmax_shape
=
layers
.
data
(
name
=
input_data_names
[
len
(
input_layers
)],
shape
=
[
2
],
dtype
=
"int32"
,
append_batch_size
=
False
)
input_layers
+=
[
src_attn_pre_softmax_shape
]
# This shape input is used to reshape after softmax in encoder-decoder
# attention.
src_attn_post_softmax_shape
=
layers
.
data
(
name
=
input_data_names
[
len
(
input_layers
)],
shape
=
[
4
],
...
...
fluid/neural_machine_translation/transformer/train.py
浏览文件 @
b34e8c0e
...
...
@@ -180,6 +180,8 @@ def main():
for
pass_id
in
xrange
(
TrainTaskConfig
.
pass_num
):
pass_start_time
=
time
.
time
()
for
batch_id
,
data
in
enumerate
(
train_data
()):
if
len
(
data
)
!=
TrainTaskConfig
.
batch_size
:
continue
data_input
=
prepare_batch_input
(
data
,
encoder_input_data_names
+
decoder_input_data_names
[:
-
1
]
+
label_data_names
,
ModelHyperParams
.
eos_idx
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录