Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
f0fc20ee
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看板
提交
f0fc20ee
编写于
5月 11, 2018
作者:
G
guosheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine docs and codes in Transformer by following comments
上级
8aa6740f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
9 deletion
+27
-9
fluid/neural_machine_translation/transformer/config.py
fluid/neural_machine_translation/transformer/config.py
+1
-1
fluid/neural_machine_translation/transformer/reader.py
fluid/neural_machine_translation/transformer/reader.py
+25
-7
fluid/neural_machine_translation/transformer/train.py
fluid/neural_machine_translation/transformer/train.py
+1
-1
未找到文件。
fluid/neural_machine_translation/transformer/config.py
浏览文件 @
f0fc20ee
...
...
@@ -5,7 +5,7 @@ class TrainTaskConfig(object):
# the number of sequences contained in a mini-batch.
batch_size
=
32
# the hyper parameters for Adam optimizer.
# This static learning_rate will
multiply
LearningRateScheduler
# This static learning_rate will
be multiplied to the
LearningRateScheduler
# derived learning rate the to get the final learning rate.
learning_rate
=
1
beta1
=
0.9
...
...
fluid/neural_machine_translation/transformer/reader.py
浏览文件 @
f0fc20ee
...
...
@@ -34,7 +34,8 @@ class Pool(object):
if
self
.
_sort
:
self
.
_pool
.
sort
(
key
=
lambda
sample
:
max
(
len
(
sample
[
0
]),
len
(
sample
[
1
]))
if
len
(
sample
)
>
1
else
len
(
sample
[
0
])
key
=
lambda
sample
:
max
(
len
(
sample
[
0
]),
len
(
sample
[
1
]))
\
if
len
(
sample
)
>
1
else
len
(
sample
[
0
])
)
if
self
.
_end
and
len
(
self
.
_pool
)
<
self
.
_pool_size
:
...
...
@@ -63,8 +64,28 @@ class Pool(object):
class
DataReader
(
object
):
"""
The data reader loads all data from files and produces batches of data
in the way corresponding to settings.
number of tokens or number of sequences.
in the way corresponding to settings. See the doc of __init__ function
for more setting details.
An example of returning a generator producing data batches whose data
is shuffled in each pass and sorted in each pool:
```
train_data = DataReader(
src_vocab_fpath='data/src_vocab_file',
trg_vocab_fpath='data/trg_vocab_file',
fpattern='data/part-*',
use_token_batch=True,
batch_size=2000,
pool_size=10000,
sort_type=SortType.POOL,
shuffle=True,
shuffle_batch=True,
start_mark='<s>',
end_mark='<e>',
unk_mark='<unk>',
clip_last_batch=False).batch_generator
```
"""
def
__init__
(
self
,
...
...
@@ -99,14 +120,11 @@ class DataReader(object):
or the maximum number of tokens (include paddings) contained in a
mini-batch.
:type batch_size: int
:param pool_size: The
buffer size to pool data
.
:param pool_size: The
size of pool buffer
.
:type pool_size: int
:param sort_type: The grain to sort by length: 'global' for all
instances; 'pool' for instances in pool; 'none' for no sort.
:type sort_type: basestring
:param sort_type: The grain to sort by length: 'global' for all
instances; 'pool' for instances in pool; 'none' for no sort.
:type sort_type: basestring
:param clip_last_batch: Whether to clip the last uncompleted batch.
:type clip_last_batch: bool
:param tar_fname: The data file in tar if fpattern matches a tar file.
...
...
fluid/neural_machine_translation/transformer/train.py
浏览文件 @
f0fc20ee
...
...
@@ -208,7 +208,7 @@ def train(args):
def
read_multiple
(
reader
,
count
=
dev_count
if
args
.
use_token_batch
else
1
,
clip_last
=
Fals
e
):
clip_last
=
Tru
e
):
"""
Stack data from reader for multi-devices.
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录