Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleFL
提交
76bd4e8d
P
PaddleFL
项目概览
PaddlePaddle
/
PaddleFL
通知
35
Star
5
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
6
列表
看板
标记
里程碑
合并请求
4
Wiki
3
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleFL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
6
Issue
6
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
3
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
76bd4e8d
编写于
4月 23, 2020
作者:
J
jingqinghe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update program_saver
上级
ab95661b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
7 deletion
+13
-7
paddle_fl/core/master/job_generator.py
paddle_fl/core/master/job_generator.py
+12
-6
paddle_fl/examples/generate_job_from_program/program_saver.py
...le_fl/examples/generate_job_from_program/program_saver.py
+1
-1
未找到文件。
paddle_fl/core/master/job_generator.py
浏览文件 @
76bd4e8d
...
@@ -199,7 +199,7 @@ class JobGenerator(object):
...
@@ -199,7 +199,7 @@ class JobGenerator(object):
local_job
.
set_strategy
(
fl_strategy
)
local_job
.
set_strategy
(
fl_strategy
)
local_job
.
save
(
output
)
local_job
.
save
(
output
)
def
save_program
(
self
,
program_path
,
loss
):
def
save_program
(
self
,
program_path
,
input_list
,
loss
):
if
not
os
.
path
.
exists
(
program_path
):
if
not
os
.
path
.
exists
(
program_path
):
os
.
makedirs
(
program_path
)
os
.
makedirs
(
program_path
)
main_program_str
=
fluid
.
default_main_program
(
main_program_str
=
fluid
.
default_main_program
(
...
@@ -210,6 +210,9 @@ class JobGenerator(object):
...
@@ -210,6 +210,9 @@ class JobGenerator(object):
para_info
=
[]
para_info
=
[]
for
pa
in
params
:
for
pa
in
params
:
para_info
.
append
(
pa
.
name
)
para_info
.
append
(
pa
.
name
)
with
open
(
program_path
+
'/input_names'
,
'w'
)
as
fout
:
for
input
in
input_list
:
fout
.
write
(
"%s
\n
"
%
input
.
name
)
with
open
(
program_path
+
'/para_info'
,
'w'
)
as
fout
:
with
open
(
program_path
+
'/para_info'
,
'w'
)
as
fout
:
for
item
in
para_info
:
for
item
in
para_info
:
fout
.
write
(
"%s
\n
"
%
item
)
fout
.
write
(
"%s
\n
"
%
item
)
...
@@ -230,12 +233,19 @@ class JobGenerator(object):
...
@@ -230,12 +233,19 @@ class JobGenerator(object):
with
open
(
program_input
+
'/main_program'
,
"rb"
)
as
fin
:
with
open
(
program_input
+
'/main_program'
,
"rb"
)
as
fin
:
program_desc_str
=
fin
.
read
()
program_desc_str
=
fin
.
read
()
new_main
=
fluid
.
Program
.
parse_from_string
(
program_desc_str
)
new_main
=
fluid
.
Program
.
parse_from_string
(
program_desc_str
)
para_list
=
[]
para_list
=
[]
with
open
(
program_input
+
'/para_info'
,
'r'
)
as
fin
:
with
open
(
program_input
+
'/para_info'
,
'r'
)
as
fin
:
for
line
in
fin
:
for
line
in
fin
:
current_para
=
line
[:
-
1
]
current_para
=
line
[:
-
1
]
para_list
.
append
(
current_para
)
para_list
.
append
(
current_para
)
input_list
=
[]
with
open
(
program_input
+
'/input_names'
,
'r'
)
as
fin
:
for
line
in
fin
:
current_input
=
line
[:
-
1
]
input_list
.
append
(
current_input
)
with
open
(
program_input
+
'/loss_name'
,
'r'
)
as
fin
:
with
open
(
program_input
+
'/loss_name'
,
'r'
)
as
fin
:
loss_name
=
fin
.
read
()
loss_name
=
fin
.
read
()
...
@@ -251,10 +261,6 @@ class JobGenerator(object):
...
@@ -251,10 +261,6 @@ class JobGenerator(object):
for
var
in
new_main
.
list_vars
():
for
var
in
new_main
.
list_vars
():
if
var
.
name
==
loss_name
:
if
var
.
name
==
loss_name
:
loss
=
var
loss
=
var
if
var
.
name
==
'input'
:
input
=
var
if
var
.
name
==
'label'
:
label
=
var
with
fluid
.
program_guard
(
new_main
,
new_startup
):
with
fluid
.
program_guard
(
new_main
,
new_startup
):
optimizer
=
fluid
.
optimizer
.
SGD
(
learning_rate
=
0.1
,
optimizer
=
fluid
.
optimizer
.
SGD
(
learning_rate
=
0.1
,
parameter_list
=
para_list
)
parameter_list
=
para_list
)
...
@@ -283,7 +289,7 @@ class JobGenerator(object):
...
@@ -283,7 +289,7 @@ class JobGenerator(object):
startup_program
=
startup_program
,
startup_program
=
startup_program
,
job
=
local_job
)
job
=
local_job
)
local_job
.
set_feed_names
(
[
input
.
name
,
label
.
name
]
)
local_job
.
set_feed_names
(
input_list
)
local_job
.
set_target_names
([
loss
.
name
])
local_job
.
set_target_names
([
loss
.
name
])
local_job
.
set_strategy
(
strategy
)
local_job
.
set_strategy
(
strategy
)
local_job
.
save
(
output
)
local_job
.
save
(
output
)
paddle_fl/examples/generate_job_from_program/program_saver.py
浏览文件 @
76bd4e8d
...
@@ -32,4 +32,4 @@ exe.run(startup_program)
...
@@ -32,4 +32,4 @@ exe.run(startup_program)
job_generator
=
JobGenerator
()
job_generator
=
JobGenerator
()
program_path
=
'./load_file'
program_path
=
'./load_file'
job_generator
.
save_program
(
program_path
,
avg_cost
)
job_generator
.
save_program
(
program_path
,
[
input
,
label
],
avg_cost
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录