Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleFL
提交
5ea8b13c
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看板
提交
5ea8b13c
编写于
1月 13, 2020
作者:
Q
qjing666
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compatibility issue
上级
757ca7c3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
6 deletion
+6
-6
paddle_fl/dataset/femnist.py
paddle_fl/dataset/femnist.py
+3
-3
paddle_fl/examples/femnist_demo/fl_trainer.py
paddle_fl/examples/femnist_demo/fl_trainer.py
+3
-3
未找到文件。
paddle_fl/dataset/femnist.py
浏览文件 @
5ea8b13c
...
...
@@ -39,10 +39,10 @@ def train(trainer_id,inner_step,batch_size,count_by_step):
train_images
=
json_train
[
"user_data"
][
cur_user
][
'x'
]
train_labels
=
json_train
[
"user_data"
][
cur_user
][
'y'
]
if
count_by_step
:
for
i
in
x
range
(
inner_step
*
batch_size
):
for
i
in
range
(
inner_step
*
batch_size
):
yield
train_images
[
i
%
(
len
(
train_images
))],
train_labels
[
i
%
(
len
(
train_images
))]
else
:
for
i
in
x
range
(
len
(
train_images
)):
for
i
in
range
(
len
(
train_images
)):
yield
train_images
[
i
],
train_labels
[
i
]
train_file
.
close
()
...
...
@@ -67,7 +67,7 @@ def test(trainer_id,inner_step,batch_size,count_by_step):
for
user
in
users
:
test_images
=
json_test
[
'user_data'
][
user
][
'x'
]
test_labels
=
json_test
[
'user_data'
][
user
][
'y'
]
for
i
in
x
range
(
len
(
test_images
)):
for
i
in
range
(
len
(
test_images
)):
yield
test_images
[
i
],
test_labels
[
i
]
test_file
.
close
()
...
...
paddle_fl/examples/femnist_demo/fl_trainer.py
浏览文件 @
5ea8b13c
...
...
@@ -40,7 +40,7 @@ def train_test(train_test_program, train_test_feed, train_test_reader):
epoch_id
=
0
step
=
0
epoch
=
3000
count_by_step
=
Fals
e
count_by_step
=
Tru
e
if
count_by_step
:
output_folder
=
"model_node%d"
%
trainer_id
else
:
...
...
@@ -66,7 +66,7 @@ while not trainer.stop():
acc
=
trainer
.
run
(
feeder
.
feed
(
data
),
fetch
=
[
"accuracy_0.tmp_0"
])
step
+=
1
count
+=
1
print
(
count
)
print
(
count
)
if
count
%
trainer
.
_step
==
0
:
break
# print("acc:%.3f" % (acc[0]))
...
...
@@ -81,5 +81,5 @@ while not trainer.stop():
print
(
"Test with epoch %d, accuracy: %s"
%
(
epoch_id
,
acc_val
))
if
trainer_id
==
0
:
save_dir
=
(
output_folder
+
"/epoch_%d"
)
%
epoch_id
save_dir
=
(
output_folder
+
"/epoch_%d"
)
%
epoch_id
trainer
.
save_inference_program
(
output_folder
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录