Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
0d4693bd
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看板
提交
0d4693bd
编写于
10月 24, 2018
作者:
Q
Qiao Longfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use logging
上级
a08c0691
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
15 deletion
+16
-15
fluid/recommendation/ctr/infer.py
fluid/recommendation/ctr/infer.py
+6
-5
fluid/recommendation/ctr/train.py
fluid/recommendation/ctr/train.py
+10
-10
未找到文件。
fluid/recommendation/ctr/infer.py
浏览文件 @
0d4693bd
import
argparse
import
time
import
logging
import
numpy
as
np
import
paddle
...
...
@@ -9,9 +9,10 @@ import reader
from
network_conf
import
ctr_dnn_model
def
print_log
(
log_str
):
time_stamp
=
time
.
strftime
(
'%Y-%m-%d %H:%M:%S'
,
time
.
localtime
(
time
.
time
()))
print
(
str
(
time_stamp
)
+
" "
+
log_str
)
logging
.
basicConfig
(
format
=
'%(asctime)s - %(levelname)s - %(message)s'
)
logger
=
logging
.
getLogger
(
"fluid"
)
logger
.
setLevel
(
logging
.
INFO
)
def
parse_args
():
...
...
@@ -70,7 +71,7 @@ def infer():
feed
=
feeder
.
feed
(
data
),
fetch_list
=
fetch_targets
)
if
batch_id
%
100
==
0
:
print_log
(
"TEST --> batch: {} loss: {} auc: {}"
.
format
(
batch_id
,
loss_val
,
auc_val
))
logger
.
info
(
"TEST --> batch: {} loss: {} auc: {}"
.
format
(
batch_id
,
loss_val
,
auc_val
))
if
__name__
==
'__main__'
:
...
...
fluid/recommendation/ctr/train.py
浏览文件 @
0d4693bd
from
__future__
import
print_function
import
argparse
import
logging
import
os
import
time
import
paddle
import
paddle.fluid
as
fluid
...
...
@@ -10,10 +10,10 @@ import paddle.fluid as fluid
import
reader
from
network_conf
import
ctr_dnn_model
def
print_log
(
log_str
):
time_stamp
=
time
.
strftime
(
'%Y-%m-%d %H:%M:%S'
,
time
.
localtime
(
time
.
time
())
)
print
(
str
(
time_stamp
)
+
" "
+
log_str
)
logging
.
basicConfig
(
format
=
'%(asctime)s - %(levelname)s - %(message)s'
)
logger
=
logging
.
getLogger
(
"fluid"
)
logger
.
setLevel
(
logging
.
INFO
)
def
parse_args
():
...
...
@@ -105,7 +105,7 @@ def train_loop(args, train_program, data_list, loss, auc_var, batch_auc_var):
feed
=
feeder
.
feed
(
data
),
fetch_list
=
[
loss
,
auc_var
,
batch_auc_var
]
)
print_log
(
"TRAIN --> pass: {} batch: {} loss: {} auc: {}, batch_auc: {}"
logger
.
info
(
"TRAIN --> pass: {} batch: {} loss: {} auc: {}, batch_auc: {}"
.
format
(
pass_id
,
batch_id
,
loss_val
/
args
.
batch_size
,
auc_val
,
batch_auc_val
))
if
batch_id
%
1000
==
0
and
batch_id
!=
0
:
model_dir
=
args
.
model_output_dir
+
'/batch-'
+
str
(
batch_id
)
...
...
@@ -127,22 +127,22 @@ def train():
optimizer
.
minimize
(
loss
)
if
args
.
is_local
:
print_log
(
"run local training"
)
logger
.
info
(
"run local training"
)
main_program
=
fluid
.
default_main_program
()
train_loop
(
args
,
main_program
,
data_list
,
loss
,
auc_var
,
batch_auc_var
)
else
:
print_log
(
"run dist training"
)
logger
.
info
(
"run dist training"
)
t
=
fluid
.
DistributeTranspiler
()
t
.
transpile
(
args
.
trainer_id
,
pservers
=
args
.
endpoints
,
trainers
=
args
.
trainers
)
if
args
.
role
==
"pserver"
:
print_log
(
"run pserver"
)
logger
.
info
(
"run pserver"
)
prog
=
t
.
get_pserver_program
(
args
.
current_endpoint
)
startup
=
t
.
get_startup_program
(
args
.
current_endpoint
,
pserver_program
=
prog
)
exe
=
fluid
.
Executor
(
fluid
.
CPUPlace
())
exe
.
run
(
startup
)
exe
.
run
(
prog
)
elif
args
.
role
==
"trainer"
:
print_log
(
"run trainer"
)
logger
.
info
(
"run trainer"
)
train_prog
=
t
.
get_trainer_program
()
train_loop
(
args
,
train_prog
,
data_list
,
loss
,
auc_var
,
batch_auc_var
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录