Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleFL
提交
a74730af
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看板
提交
a74730af
编写于
9月 16, 2020
作者:
H
He, Kai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add decrypt_and_rescale.py to mean_normalize_demo
上级
63ae7e62
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
4 deletion
+44
-4
python/paddle_fl/mpc/examples/mean_normalize_demo/README.md
python/paddle_fl/mpc/examples/mean_normalize_demo/README.md
+9
-4
python/paddle_fl/mpc/examples/mean_normalize_demo/decrypt_and_rescale.py
...l/mpc/examples/mean_normalize_demo/decrypt_and_rescale.py
+35
-0
未找到文件。
python/paddle_fl/mpc/examples/mean_normalize_demo/README.md
浏览文件 @
a74730af
...
@@ -11,8 +11,9 @@ Create a empty dir for data, and modify `data_path` in `process_data.py`,
...
@@ -11,8 +11,9 @@ Create a empty dir for data, and modify `data_path` in `process_data.py`,
default dir path is
`./data`
.
default dir path is
`./data`
.
Then run the script with command
`python prepare.py`
to generate random data
Then run the script with command
`python prepare.py`
to generate random data
for demo. Otherwise generate your own data, move them to
`data_path`
and modify
for demo, which is dumped by numpy and named
`feature_data.{i}.npy`
located
corresponding meta info in
`prepare.py`
.
in
`data_path`
. Otherwise generate your own data, move them to
`data_path`
,
name as the same way, and modify corresponding meta info in
`prepare.py`
.
Encrypted data files of feature statstics would be generated and saved in
Encrypted data files of feature statstics would be generated and saved in
`data_path`
directory. Different suffix names are used for these files to
`data_path`
directory. Different suffix names are used for these files to
...
@@ -55,5 +56,9 @@ import process_data
...
@@ -55,5 +56,9 @@ import process_data
res
=
process_data
.
decrypt_data
(
prepare
.
data_path
+
'result'
,
(
2
,
prepare
.
feat_width
,
))
res
=
process_data
.
decrypt_data
(
prepare
.
data_path
+
'result'
,
(
2
,
prepare
.
feat_width
,
))
```
```
Also,
`verify.py`
could be used to calculate error between direct plaintext
Or use
`decrypt_and_rescale.py`
to decrypt, rescale the feature data which has
numpy calculation and mpc mean normalize.
been saved in
`feature_data.{i}.npy`
, and dump the normalized data to
`normalized_data.{i}.npy`
which is located in
`data_path`
.
Also,
`verify.py`
could be used to calculate error of
`f_range`
and
`f_mean`
between direct plaintext numpy calculation and mpc mean normalize.
python/paddle_fl/mpc/examples/mean_normalize_demo/decrypt_and_rescale.py
0 → 100644
浏览文件 @
a74730af
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Decrypt and rescale for mean normalize demo.
"""
import
sys
import
numpy
as
np
import
process_data
import
prepare
data_path
=
prepare
.
data_path
# 0 for f_range, 1 for f_mean
# use decrypted global f_range and f_mean to rescaling local feature data
res
=
process_data
.
decrypt_data
(
data_path
+
'result'
,
(
2
,
prepare
.
feat_width
,
))
party
=
sys
.
argv
[
1
]
input
=
np
.
load
(
data_path
+
'feature_data.'
+
party
+
'.npy'
)
output
=
(
input
-
res
[
1
])
/
res
[
0
]
np
.
save
(
data_path
+
'normalized_data.'
+
party
,
output
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录