Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
e4e73df6
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看板
提交
e4e73df6
编写于
11月 27, 2018
作者:
L
Liang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add paddle_cloud_train of ctr
上级
19b08cfd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
3 deletion
+36
-3
fluid/PaddleRec/ctr/train.py
fluid/PaddleRec/ctr/train.py
+36
-3
未找到文件。
fluid/PaddleRec/ctr/train.py
浏览文件 @
e4e73df6
...
...
@@ -56,12 +56,26 @@ def parse_args():
type
=
int
,
default
=
1000001
,
help
=
'sparse feature hashing space for index processing'
)
parser
.
add_argument
(
'--is_local'
,
type
=
int
,
default
=
1
,
help
=
'Local train or distributed train (default: 1)'
)
parser
.
add_argument
(
'--cloud_train'
,
type
=
int
,
default
=
0
,
help
=
'Local train or distributed train on paddlecloud (default: 0)'
)
parser
.
add_argument
(
'--async_mode'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Whether start pserver in async mode to support ASGD'
)
parser
.
add_argument
(
'--no_split_var'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Whether split variables into blocks when update_method is pserver'
)
# the following arguments is used for distributed train, if is_local == false, then you should set them
parser
.
add_argument
(
'--role'
,
...
...
@@ -134,6 +148,21 @@ def train():
loss
,
data_list
,
auc_var
,
batch_auc_var
=
ctr_dnn_model
(
args
.
embedding_size
,
args
.
sparse_feature_dim
)
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
1e-4
)
optimizer
.
minimize
(
loss
)
if
args
.
cloud_train
:
# the port of all pservers, needed by both trainer and pserver
port
=
os
.
getenv
(
"PADDLE_PORT"
,
"6174"
)
# comma separated ips of all pservers, needed by trainer and
pserver_ips
=
os
.
getenv
(
"PADDLE_PSERVERS"
,
""
)
eplist
=
[]
for
ip
in
pserver_ips
.
split
(
","
):
eplist
.
append
(
':'
.
join
([
ip
,
port
]))
args
.
endpoints
=
","
.
join
(
eplist
)
args
.
trainers
=
int
(
os
.
getenv
(
"PADDLE_TRAINERS_NUM"
,
"1"
))
args
.
current_endpoint
=
os
.
getenv
(
"POD_IP"
,
"localhost"
)
+
":"
+
port
args
.
role
=
os
.
getenv
(
"TRAINING_ROLE"
,
"TRAINER"
)
args
.
trainer_id
=
int
(
os
.
getenv
(
"PADDLE_TRAINER_ID"
,
"0"
))
args
.
is_local
=
bool
(
int
(
os
.
getenv
(
"PADDLE_IS_LOCAL"
,
0
)))
if
args
.
is_local
:
logger
.
info
(
"run local training"
)
...
...
@@ -143,18 +172,22 @@ def train():
logger
.
info
(
"run dist training"
)
t
=
fluid
.
DistributeTranspiler
()
t
.
transpile
(
args
.
trainer_id
,
pservers
=
args
.
endpoints
,
trainers
=
args
.
trainers
)
if
args
.
role
==
"pserver"
:
if
args
.
role
==
"pserver"
or
args
.
role
==
"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"
:
elif
args
.
role
==
"trainer"
or
args
.
role
==
"TRAINING_ROLE"
:
logger
.
info
(
"run trainer"
)
train_prog
=
t
.
get_trainer_program
()
train_loop
(
args
,
train_prog
,
data_list
,
loss
,
auc_var
,
batch_auc_var
,
args
.
trainers
,
args
.
trainer_id
)
else
:
raise
ValueError
(
'PADDLE_TRAINING_ROLE environment variable must be either TRAINER or PSERVER'
)
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录