Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
898f0c51
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看板
提交
898f0c51
编写于
4月 13, 2018
作者:
G
gongweibao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add speed
上级
44ad16aa
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
13 addition
and
4 deletion
+13
-4
fluid/neural_machine_translation/transformer_nist_base/nmt_fluid.py
...al_machine_translation/transformer_nist_base/nmt_fluid.py
+13
-4
未找到文件。
fluid/neural_machine_translation/transformer_nist_base/nmt_fluid.py
浏览文件 @
898f0c51
...
...
@@ -233,11 +233,16 @@ def main():
position_encoding_init
(
ModelHyperParams
.
max_length
+
1
,
ModelHyperParams
.
d_model
),
place
)
for
pass_id
in
xrange
(
TrainTaskConfig
.
pass_num
):
pass_start_time
=
time
.
time
()
def
train_loop
(
exe
,
trainer_prog
):
for
pass_id
in
xrange
(
args
.
pass_num
):
ts
=
time
.
time
()
total
=
0
for
batch_id
,
data
in
enumerate
(
train_reader
()):
if
len
(
data
)
!=
TrainTaskConfig
.
batch_size
:
continue
total
+=
len
(
data
)
start_time
=
time
.
time
()
data_input
=
prepare_batch_input
(
data
,
encoder_input_data_names
+
decoder_input_data_names
[:
-
1
]
+
label_data_names
,
ModelHyperParams
.
eos_idx
,
...
...
@@ -249,15 +254,19 @@ def main():
fetch_list
=
[
sum_cost
,
avg_cost
],
use_program_cache
=
True
)
sum_cost_val
,
avg_cost_val
=
np
.
array
(
outs
[
0
]),
np
.
array
(
outs
[
1
])
print
(
"epoch: %d, batch: %d, sum loss: %f, avg loss: %f, ppl: %f"
%
print
(
"epoch: %d, batch: %d, sum loss: %f, avg loss: %f, ppl: %f
, speed=%.2f /s
"
%
(
pass_id
,
batch_id
,
sum_cost_val
,
avg_cost_val
,
np
.
exp
([
min
(
avg_cost_val
[
0
],
100
)])))
np
.
exp
([
min
(
avg_cost_val
[
0
],
100
)]),
len
(
data
)
/
(
time
.
time
()
-
start_time
)))
# Validate and save the model for inference.
#val_avg_cost, val_ppl = test(exe)
pass_end_time
=
time
.
time
()
time_consumed
=
pass_end_time
-
pass_start_time
print
(
"pass_id = "
+
str
(
pass_id
)
+
" time_consumed = "
+
str
(
time_consumed
))
print
(
"pass_id = %d cost = %f avg_speed = %.2f sample/s"
%
(
pass_id
,
val_cost
,
total
/
(
time
.
time
()
-
ts
)))
#print("epoch: %d, val avg loss: %f, val ppl: %f, "
# "consumed %fs" % (pass_id, val_avg_cost, val_ppl, time_consumed))
fluid
.
io
.
save_inference_model
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录