Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
67f0fe7a
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看板
未验证
提交
67f0fe7a
编写于
6月 19, 2019
作者:
C
chengduo
提交者:
GitHub
6月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update transformer (#2444)
* update transformer
上级
3370e5f6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
6 deletion
+10
-6
PaddleNLP/neural_machine_translation/transformer/train.py
PaddleNLP/neural_machine_translation/transformer/train.py
+10
-6
未找到文件。
PaddleNLP/neural_machine_translation/transformer/train.py
浏览文件 @
67f0fe7a
...
...
@@ -376,7 +376,8 @@ def py_reader_provider_wrapper(data_reader, place):
data
,
data_input_names
,
ModelHyperParams
.
eos_idx
,
ModelHyperParams
.
eos_idx
,
ModelHyperParams
.
n_head
,
ModelHyperParams
.
d_model
)
yield
[
data_input_dict
[
item
]
for
item
in
data_input_names
]
total_dict
=
dict
(
data_input_dict
.
items
())
yield
[
total_dict
[
item
]
for
item
in
data_input_names
]
return
py_reader_provider
...
...
@@ -422,14 +423,11 @@ def test_context(exe, train_exe, dev_count):
fluid
.
io
.
load_persistables
(
exe
,
TrainTaskConfig
.
ckpt_path
,
main_program
=
test_prog
)
exec_strategy
=
fluid
.
ExecutionStrategy
()
exec_strategy
.
use_experimental_executor
=
True
build_strategy
=
fluid
.
BuildStrategy
()
test_exe
=
fluid
.
ParallelExecutor
(
use_cuda
=
TrainTaskConfig
.
use_gpu
,
main_program
=
test_prog
,
build_strategy
=
build_strategy
,
exec_strategy
=
exec_strategy
,
share_vars_from
=
train_exe
)
def
test
(
exe
=
test_exe
,
pyreader
=
pyreader
):
...
...
@@ -494,13 +492,18 @@ def train_loop(exe,
# For faster executor
exec_strategy
=
fluid
.
ExecutionStrategy
()
exec_strategy
.
use_experimental_executor
=
True
exec_strategy
.
num_iteration_per_drop_scope
=
int
(
args
.
fetch_steps
)
build_strategy
=
fluid
.
BuildStrategy
()
build_strategy
.
memory_optimize
=
False
build_strategy
.
enable_inplace
=
True
sum_cost
.
persistable
=
True
token_num
.
persistable
=
True
# Since the token number differs among devices, customize gradient scale to
# use token average cost among multi-devices. and the gradient scale is
# `1 / token_number` for average cost.
# build_strategy.gradient_scale_strategy = fluid.BuildStrategy.GradientScaleStrategy.Customized
build_strategy
.
fuse_all_optimizer_ops
=
True
logging
.
info
(
"begin executor"
)
train_exe
=
fluid
.
ParallelExecutor
(
...
...
@@ -632,7 +635,8 @@ def train(args):
place
=
fluid
.
CPUPlace
()
dev_count
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
multiprocessing
.
cpu_count
()))
else
:
place
=
fluid
.
CUDAPlace
(
0
)
gpu_id
=
int
(
os
.
environ
.
get
(
'FLAGS_selected_gpus'
,
0
))
place
=
fluid
.
CUDAPlace
(
gpu_id
)
dev_count
=
fluid
.
core
.
get_cuda_device_count
()
exe
=
fluid
.
Executor
(
place
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录