Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一只大灰猫
PaddleRec
提交
a82671c4
P
PaddleRec
项目概览
一只大灰猫
/
PaddleRec
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleRec
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleRec
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a82671c4
编写于
5月 06, 2020
作者:
C
chengmo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix sgd flags
上级
8a9fc7c6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
4 deletion
+13
-4
fleet_rec/core/trainers/cluster_trainer.py
fleet_rec/core/trainers/cluster_trainer.py
+7
-3
fleet_rec/core/trainers/tdm_cluster_trainer.py
fleet_rec/core/trainers/tdm_cluster_trainer.py
+5
-1
fleet_rec/core/trainers/tdm_single_trainer.py
fleet_rec/core/trainers/tdm_single_trainer.py
+1
-0
未找到文件。
fleet_rec/core/trainers/cluster_trainer.py
浏览文件 @
a82671c4
...
@@ -43,7 +43,8 @@ class ClusterTrainer(TranspileTrainer):
...
@@ -43,7 +43,8 @@ class ClusterTrainer(TranspileTrainer):
if
envs
.
get_platform
()
==
"LINUX"
:
if
envs
.
get_platform
()
==
"LINUX"
:
self
.
regist_context_processor
(
'train_pass'
,
self
.
dataset_train
)
self
.
regist_context_processor
(
'train_pass'
,
self
.
dataset_train
)
else
:
else
:
self
.
regist_context_processor
(
'train_pass'
,
self
.
dataloader_train
)
self
.
regist_context_processor
(
'train_pass'
,
self
.
dataloader_train
)
self
.
regist_context_processor
(
'terminal_pass'
,
self
.
terminal
)
self
.
regist_context_processor
(
'terminal_pass'
,
self
.
terminal
)
def
build_strategy
(
self
):
def
build_strategy
(
self
):
...
@@ -70,6 +71,9 @@ class ClusterTrainer(TranspileTrainer):
...
@@ -70,6 +71,9 @@ class ClusterTrainer(TranspileTrainer):
def
init
(
self
,
context
):
def
init
(
self
,
context
):
self
.
model
.
train_net
()
self
.
model
.
train_net
()
optimizer
=
self
.
model
.
optimizer
()
optimizer
=
self
.
model
.
optimizer
()
optimizer_name
=
envs
.
get_global_env
(
"hyper_parameters.optimizer"
)
if
optimizer_name
in
[
'adam'
,
'ADAM'
,
'Adagrad'
,
'ADAGRAD'
]:
os
.
environ
[
"FLAGS_communicator_is_sgd_optimizer"
]
=
0
strategy
=
self
.
build_strategy
()
strategy
=
self
.
build_strategy
()
optimizer
=
fleet
.
distributed_optimizer
(
optimizer
,
strategy
)
optimizer
=
fleet
.
distributed_optimizer
(
optimizer
,
strategy
)
optimizer
.
minimize
(
self
.
model
.
get_cost_op
())
optimizer
.
minimize
(
self
.
model
.
get_cost_op
())
...
@@ -103,8 +107,8 @@ class ClusterTrainer(TranspileTrainer):
...
@@ -103,8 +107,8 @@ class ClusterTrainer(TranspileTrainer):
program
=
fluid
.
compiler
.
CompiledProgram
(
program
=
fluid
.
compiler
.
CompiledProgram
(
fleet
.
main_program
).
with_data_parallel
(
fleet
.
main_program
).
with_data_parallel
(
loss_name
=
self
.
model
.
get_cost_op
().
name
,
loss_name
=
self
.
model
.
get_cost_op
().
name
,
build_strategy
=
self
.
strategy
.
get_build_strategy
(),
build_strategy
=
self
.
strategy
.
get_build_strategy
(),
exec_strategy
=
self
.
strategy
.
get_execute_strategy
())
exec_strategy
=
self
.
strategy
.
get_execute_strategy
())
metrics_varnames
=
[]
metrics_varnames
=
[]
metrics_format
=
[]
metrics_format
=
[]
...
...
fleet_rec/core/trainers/tdm_cluster_trainer.py
浏览文件 @
a82671c4
...
@@ -75,6 +75,9 @@ class TDMClusterTrainer(TranspileTrainer):
...
@@ -75,6 +75,9 @@ class TDMClusterTrainer(TranspileTrainer):
def
init
(
self
,
context
):
def
init
(
self
,
context
):
self
.
model
.
train_net
()
self
.
model
.
train_net
()
optimizer
=
self
.
model
.
optimizer
()
optimizer
=
self
.
model
.
optimizer
()
optimizer_name
=
envs
.
get_global_env
(
"hyper_parameters.optimizer"
)
if
optimizer_name
in
[
'adam'
,
'ADAM'
,
'Adagrad'
,
'ADAGRAD'
]:
os
.
environ
[
"FLAGS_communicator_is_sgd_optimizer"
]
=
0
strategy
=
self
.
build_strategy
()
strategy
=
self
.
build_strategy
()
optimizer
=
fleet
.
distributed_optimizer
(
optimizer
,
strategy
)
optimizer
=
fleet
.
distributed_optimizer
(
optimizer
,
strategy
)
optimizer
.
minimize
(
self
.
model
.
get_cost_op
())
optimizer
.
minimize
(
self
.
model
.
get_cost_op
())
...
@@ -93,6 +96,7 @@ class TDMClusterTrainer(TranspileTrainer):
...
@@ -93,6 +96,7 @@ class TDMClusterTrainer(TranspileTrainer):
context
[
'status'
]
=
'trainer_startup_pass'
context
[
'status'
]
=
'trainer_startup_pass'
def
server
(
self
,
context
):
def
server
(
self
,
context
):
namespace
=
"train.startup"
model_path
=
envs
.
get_global_env
(
model_path
=
envs
.
get_global_env
(
"cluster.model_path"
,
""
,
namespace
)
"cluster.model_path"
,
""
,
namespace
)
assert
not
model_path
,
"Cluster train must has init_model for TDM"
assert
not
model_path
,
"Cluster train must has init_model for TDM"
...
@@ -103,7 +107,7 @@ class TDMClusterTrainer(TranspileTrainer):
...
@@ -103,7 +107,7 @@ class TDMClusterTrainer(TranspileTrainer):
def
trainer_startup
(
self
,
context
):
def
trainer_startup
(
self
,
context
):
namespace
=
"train.startup"
namespace
=
"train.startup"
load_tree
=
envs
.
get_global_env
(
load_tree
=
envs
.
get_global_env
(
"cluster.load_tree"
,
Fals
e
,
namespace
)
"cluster.load_tree"
,
Tru
e
,
namespace
)
self
.
tree_layer_path
=
envs
.
get_global_env
(
self
.
tree_layer_path
=
envs
.
get_global_env
(
"cluster.tree_layer_path"
,
""
,
namespace
)
"cluster.tree_layer_path"
,
""
,
namespace
)
self
.
tree_travel_path
=
envs
.
get_global_env
(
self
.
tree_travel_path
=
envs
.
get_global_env
(
...
...
fleet_rec/core/trainers/tdm_single_trainer.py
浏览文件 @
a82671c4
# -*- coding=utf-8 -*-
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录