Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
75594b98
M
models
项目概览
PaddlePaddle
/
models
接近 2 年 前同步成功
通知
230
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看板
未验证
提交
75594b98
编写于
11月 12, 2018
作者:
Y
Yibing Liu
提交者:
GitHub
11月 12, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable model ce for dam (#1447)
* Enable model ce for dam * Uncomment mem opt
上级
55737d59
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
81 addition
and
6 deletion
+81
-6
fluid/PaddleNLP/deep_attention_matching_net/.run_ce.sh
fluid/PaddleNLP/deep_attention_matching_net/.run_ce.sh
+15
-0
fluid/PaddleNLP/deep_attention_matching_net/_ce.py
fluid/PaddleNLP/deep_attention_matching_net/_ce.py
+46
-0
fluid/PaddleNLP/deep_attention_matching_net/train_and_evaluate.py
...ddleNLP/deep_attention_matching_net/train_and_evaluate.py
+19
-6
fluid/PaddleNLP/deep_attention_matching_net/utils/reader.py
fluid/PaddleNLP/deep_attention_matching_net/utils/reader.py
+1
-0
未找到文件。
fluid/PaddleNLP/deep_attention_matching_net/.run_ce.sh
0 → 100755
浏览文件 @
75594b98
###!/bin/bash
####This file is only used for continuous evaluation.
export
CE_MODE_X
=
1
export
CUDA_VISIBLE_DEVICES
=
0
export
FLAGS_eager_delete_tensor_gb
=
0.0
if
[
!
-e
data_small.pkl
]
;
then
wget
-c
http://dam-data.bj.bcebos.com/data_small.pkl
fi
python train_and_evaluate.py
--data_path
data_small.pkl
\
--use_cuda
\
--use_pyreader
\
--num_scan_data
1
\
--batch_size
100 | python _ce.py
fluid/PaddleNLP/deep_attention_matching_net/_ce.py
0 → 100644
浏览文件 @
75594b98
####this file is only used for continuous evaluation test!
import
os
import
sys
sys
.
path
.
append
(
os
.
environ
[
'ceroot'
])
from
kpi
import
CostKpi
,
DurationKpi
,
AccKpi
#### NOTE kpi.py should shared in models in some way!!!!
train_cost_kpi
=
CostKpi
(
'train_cost'
,
0.02
,
actived
=
True
)
train_duration_kpi
=
DurationKpi
(
'train_duration'
,
0.05
,
actived
=
True
)
tracking_kpis
=
[
train_cost_kpi
,
train_duration_kpi
,
]
def
parse_log
(
log
):
for
line
in
log
.
split
(
'
\n
'
):
fs
=
line
.
strip
().
split
(
'
\t
'
)
print
(
fs
)
if
len
(
fs
)
==
3
and
fs
[
0
]
==
'kpis'
:
print
(
"-----%s"
%
fs
)
kpi_name
=
fs
[
1
]
kpi_value
=
float
(
fs
[
2
])
yield
kpi_name
,
kpi_value
def
log_to_ce
(
log
):
kpi_tracker
=
{}
for
kpi
in
tracking_kpis
:
kpi_tracker
[
kpi
.
name
]
=
kpi
for
(
kpi_name
,
kpi_value
)
in
parse_log
(
log
):
print
(
kpi_name
,
kpi_value
)
kpi_tracker
[
kpi_name
].
add_record
(
kpi_value
)
kpi_tracker
[
kpi_name
].
persist
()
if
__name__
==
'__main__'
:
log
=
sys
.
stdin
.
read
()
print
(
"*****"
)
print
(
log
)
print
(
"****"
)
log_to_ce
(
log
)
fluid/PaddleNLP/deep_attention_matching_net/train_and_evaluate.py
浏览文件 @
75594b98
...
...
@@ -192,6 +192,9 @@ def train(args):
train_program
=
fluid
.
Program
()
train_startup
=
fluid
.
Program
()
if
"CE_MODE_X"
in
os
.
environ
:
train_program
.
random_seed
=
110
train_startup
.
random_seed
=
110
with
fluid
.
program_guard
(
train_program
,
train_startup
):
with
fluid
.
unique_name
.
guard
():
if
args
.
use_pyreader
:
...
...
@@ -217,6 +220,9 @@ def train(args):
test_program
=
fluid
.
Program
()
test_startup
=
fluid
.
Program
()
if
"CE_MODE_X"
in
os
.
environ
:
test_program
.
random_seed
=
110
test_startup
.
random_seed
=
110
with
fluid
.
program_guard
(
test_program
,
test_startup
):
with
fluid
.
unique_name
.
guard
():
if
args
.
use_pyreader
:
...
...
@@ -322,7 +328,7 @@ def train(args):
result_file_path
=
os
.
path
.
join
(
args
.
save_path
,
'result.'
+
str
(
step
))
evaluate
(
score_path
,
result_file_path
)
return
step
return
step
,
np
.
array
(
cost
[
0
]).
mean
()
# train on one epoch with pyreader
def
train_with_pyreader
(
step
):
...
...
@@ -367,18 +373,25 @@ def train(args):
except
fluid
.
core
.
EOFException
:
train_pyreader
.
reset
()
break
return
step
return
step
,
np
.
array
(
cost
[
0
]).
mean
()
# train over different epoches
global_step
=
0
global_step
,
train_time
=
0
,
0.
0
for
epoch
in
six
.
moves
.
xrange
(
args
.
num_scan_data
):
shuffle_train
=
reader
.
unison_shuffle
(
train_data
)
shuffle_train
=
reader
.
unison_shuffle
(
train_data
,
seed
=
110
if
(
"CE_MODE_X"
in
os
.
environ
)
else
None
)
train_batches
=
reader
.
build_batches
(
shuffle_train
,
data_conf
)
begin_time
=
time
.
time
()
if
args
.
use_pyreader
:
global_step
=
train_with_pyreader
(
global_step
)
global_step
,
last_cost
=
train_with_pyreader
(
global_step
)
else
:
global_step
=
train_with_feed
(
global_step
)
global_step
,
last_cost
=
train_with_feed
(
global_step
)
train_time
+=
time
.
time
()
-
begin_time
# For internal continuous evaluation
if
"CE_MODE_X"
in
os
.
environ
:
print
(
"kpis train_cost %f"
%
last_cost
)
print
(
"kpis train_duration %f"
%
train_time
)
if
__name__
==
'__main__'
:
...
...
fluid/PaddleNLP/deep_attention_matching_net/utils/reader.py
浏览文件 @
75594b98
...
...
@@ -17,6 +17,7 @@ def unison_shuffle(data, seed=None):
assert
len
(
y
)
==
len
(
c
)
==
len
(
r
)
p
=
np
.
random
.
permutation
(
len
(
y
))
print
(
p
)
shuffle_data
=
{
six
.
b
(
'y'
):
y
[
p
],
six
.
b
(
'c'
):
c
[
p
],
six
.
b
(
'r'
):
r
[
p
]}
return
shuffle_data
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录