Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleFL
提交
682ab437
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看板
提交
682ab437
编写于
7月 31, 2020
作者:
H
heya02
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update scripts and add param for mnist_demo.py
上级
459ee84a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
26 addition
and
11 deletion
+26
-11
python/paddle_fl/mpc/examples/mnist_demo/mnist_demo.py
python/paddle_fl/mpc/examples/mnist_demo/mnist_demo.py
+11
-6
python/paddle_fl/mpc/examples/mnist_demo/run_standalone.sh
python/paddle_fl/mpc/examples/mnist_demo/run_standalone.sh
+15
-5
未找到文件。
python/paddle_fl/mpc/examples/mnist_demo/mnist_demo.py
浏览文件 @
682ab437
...
...
@@ -16,6 +16,7 @@ MNIST Demo
"""
import
sys
import
os
import
numpy
as
np
import
time
...
...
@@ -26,9 +27,11 @@ import paddle_fl.mpc as pfl_mpc
import
paddle_fl.mpc.data_utils.aby3
as
aby3
env_dist
=
os
.
environ
local_host
=
env_dist
.
get
(
'LOCALHOST'
)
role
,
server
,
port
=
sys
.
argv
[
1
],
sys
.
argv
[
2
],
sys
.
argv
[
3
]
# modify host(localhost).
pfl_mpc
.
init
(
"aby3"
,
int
(
role
),
"localhost"
,
server
,
int
(
port
))
pfl_mpc
.
init
(
"aby3"
,
int
(
role
),
local_host
,
server
,
int
(
port
))
role
=
int
(
role
)
# data preprocessing
...
...
@@ -78,18 +81,20 @@ test_loader.set_batch_generator(test_batch_sample, places=place)
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
start_time
=
time
.
time
()
step
=
0
for
epoch_id
in
range
(
epoch_num
):
start_time
=
time
.
time
()
step
=
0
# feed data via loader
for
sample
in
loader
():
batch_start
=
time
.
time
()
exe
.
run
(
feed
=
sample
,
fetch_list
=
[
cost
.
name
])
batch_end
=
time
.
time
()
if
step
%
50
==
0
:
print
(
'Epoch={}, Step={}
'
.
format
(
epoch_id
,
step
))
print
(
'Epoch={}, Step={}
, batch_cost={:.4f} s'
.
format
(
epoch_id
,
step
,
(
batch_end
-
batch_start
)
))
step
+=
1
end_time
=
time
.
time
()
print
(
'Mpc Training of Epoch={} Batch_size={}, cost time in seconds:{}
'
end_time
=
time
.
time
()
print
(
'Mpc Training of Epoch={} Batch_size={}, epoch_cost={:.4f} s
'
.
format
(
epoch_num
,
BATCH_SIZE
,
(
end_time
-
start_time
)))
# prediction
...
...
python/paddle_fl/mpc/examples/mnist_demo/run_standalone.sh
浏览文件 @
682ab437
...
...
@@ -31,12 +31,13 @@
# bash run_standalone.sh TEST_SCRIPT_NAME
#
#
modify the following vars according to
your environment
PYTHON
=
"python"
REDIS_HOME
=
"path_to_redis_bin"
SERVER
=
"localhost"
PORT
=
9937
#
please set the following environment vars according in
your environment
PYTHON
=
${
PYTHON
}
REDIS_HOME
=
${
PATH_TO_REDIS_BIN
}
SERVER
=
${
LOCALHOST
}
PORT
=
${
REDIS_PORT
}
echo
"redis home in
${
REDIS_HOME
}
, server is
${
SERVER
}
, port is
${
PORT
}
"
function
usage
()
{
echo
'run_standalone.sh SCRIPT_NAME [ARG...]'
exit
0
...
...
@@ -67,6 +68,15 @@ if [ "$PRED_FILE" ]; then
rm
-rf
$PRED_FILE
fi
PRED_FILE
=
"/tmp/mnist2_feature.part*"
if
[
!
"
$PRED_FILE
"
]
;
then
echo
"There is no data in /tmp, please prepare data with "
python prepare.py
" firstly"
exit
1
else
echo
"There are data for mnist:"
echo
"
`
ls
${
PRED_FILE
}
`
"
fi
# kick off script with roles of 1 and 2, and redirect output to /dev/null
for
role
in
{
1..2
}
;
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录