提交 92a5b8de 编写于 作者: J jingqinghe

update document

上级 d588179b
......@@ -121,6 +121,7 @@ In PaddleFL, components for defining a federated learning task and training a fe
- **FL-scheduler**: Decide which set of trainers can join the training before each updating cycle.
For more instructions, please refer to the [examples](./python/paddle_fl/paddle_fl/examples)
### Paddle Encrypted
Paddle Fluid Encrypted implements secure training and inference tasks based on the underlying MPC protocol of ABY3[], in which participants can be classified into roles of Input Party (IP), Computing Party (CP) and Result Party (RP).
......@@ -161,6 +162,7 @@ A PFE program is exactly a PaddlePaddle program, and will be executed as normal
Upon completion of the secure training (or inference) job, the models (or prediction results) will be output by CPs in encrypted form. Result Parties can collect the encrypted results, decrypt them using the tools in PFE, and deliver the plaintext results to users.
For more instructions, please refer to [mpc examples](./python/paddle_fl/mpc/examples)
## Easy deployment with kubernetes
### Horizontal Federated Learning
......
......@@ -64,6 +64,7 @@ Paddle Encrypted 设计与PaddlePaddle相似,没有密码学相关背景的用
- **FL-Scheduler**: 训练过程中起到调度Worker的作用,在每个更新周期前,决定哪些Worker可以参与训练。
请参考更多的[例子](./python/paddle_fl/paddle_fl/examples), 获取更多的信息。
### Paddle Encrypted
Paddle Encrypted 中的安全训练和推理任务是基于底层的ABY3多方计算协议实现的。在ABY3中,参与方可分为:输入方、计算方和结果方。
......@@ -98,6 +99,8 @@ Paddle Encrypted允许数据拥有方(数据方)在不泄露自己数据的
#### 结果重构
安全训练和推理工作完成后,模型(或预测结果)将由计算方以加密形式输出。结果方可以收集加密的结果,使用Paddle Encrypted中的工具对其进行解密,并将明文结果传递给用户。
请参考[MPC的例子](./python/paddle_fl/mpc/examples),以获取更多的信息。
## Kubernetes简单部署
### 横向联邦方案
......
##Instructions for PaddleFL-MPC MNIST Demo
## Instructions for PaddleFL-MPC MNIST Demo
([简体中文](./README_CN.md)|English)
This document introduces how to run MNIST demo based on Paddle-MPC, which has two ways of running, i.e., single machine and multi machines.
###1. Running on Single Machine
### 1. Running on Single Machine
####(1). Prepare Data
#### (1). Prepare Data
Generate encrypted training and testing data utilizing `generate_encrypted_data()` and `generate_encrypted_test_data()` in `process_data.py` script. For example, users can write the following code into a python script named `prepare.py`, and then run the script with command `python prepare.py`.
......@@ -18,7 +18,7 @@ process_data.generate_encrypted_test_data()
Encrypted data files of feature and label would be generated and saved in `/tmp` directory. Different suffix names are used for these files to indicate the ownership of different computation parties. For instance, a file named `mnist2_feature.part0` means it is a feature file of party 0.
####(2). Launch Demo with A Shell Script
#### (2). Launch Demo with A Shell Script
Launch demo with the `run_standalone.sh` script. The concrete command is:
......@@ -30,7 +30,7 @@ The information of current epoch and step will be displayed on screen while trai
Besides, predictions would be made in this demo once training is finished. The predictions with cypher text format would be save in `/tmp` directory, and the format of file name is similar to what is described in Step 1.
####(3). Decrypt Data
#### (3). Decrypt Data
Decrypt the saved prediction data and save the decrypted prediction results into a specified file using `decrypt_data_to_file()` in `process_data.py` script. For example, users can write the following code into a python script named `decrypt_save.py`, and then run the script with command `python decrypt_save.py`. The decrypted prediction results would be saved into `mpc_label`.
......@@ -51,17 +51,17 @@ fi
###2. Running on Multi Machines
### 2. Running on Multi Machines
####(1). Prepare Data
#### (1). Prepare Data
Data owner encrypts data. Concrete operations are consistent with “Prepare Data” in “Running on Single Machine”.
####(2). Distribute Encrypted Data
#### (2). Distribute Encrypted Data
According to the suffix of file name, distribute encrypted data files to `/tmp ` directories of all 3 computation parties. For example, send `mnist2_feature.part0` and `mnist2_label.part0` to `/tmp` of party 0 with `scp` command.
####(3). Modify mnist_demo.py
#### (3). Modify mnist_demo.py
Each computation party modifies `localhost` in the following code as the IP address of it's machine.
......@@ -69,7 +69,7 @@ Each computation party modifies `localhost` in the following code as the IP addr
pfl_mpc.init("aby3", int(role), "localhost", server, int(port))
```
####(4). Launch Demo on Each Party
#### (4). Launch Demo on Each Party
**Note** that Redis service is necessary for demo running. Remember to clear the cache of Redis server before launching demo on each computation party, in order to avoid any negative influences caused by the cached records in Redis. The following command can be used for clear Redis, where REDIS_BIN is the executable binary of redis-cli, SERVER and PORT represent the IP and port of Redis server respectively.
......@@ -89,7 +89,7 @@ Similarly, predictions with cypher text format would be saved in `/tmp` director
**Note** that remember to delete the precidtion files in `/tmp` directory generated in last running, in case of any influence on the decrypted results of current running.
####(5). Decrypt Prediction Data
#### (5). Decrypt Prediction Data
Each computation party sends `mnist_output_prediction.part` file in `/tmp` directory to the `/tmp` directory of data owner. Data owner decrypts the prediction data and saves the decrypted prediction results into a specified file using `decrypt_data_to_file()` in `process_data.py` script. For example, users can write the following code into a python script named `decrypt_save.py`, and then run the script with command `python decrypt_save.py`. The decrypted prediction results would be saved into file `mpc_label`.
......
##PaddleFL-MPC MNIST Demo运行说明
## PaddleFL-MPC MNIST Demo运行说明
(简体中文|[English](./README.md))
本示例介绍基于PaddleFL-MPC进行MNIST数据集模型训练和预测的使用说明,分为单机运行和多机运行两种方式。
###一. 单机运行
### 一. 单机运行
####1. 准备数据
#### 1. 准备数据
使用`process_data.py`脚本中的`generate_encrypted_data()``generate_encrypted_test_data()`产生加密训练数据和测试数据,比如将如下内容写到一个`prepare.py`脚本中,然后`python prepare.py`
......@@ -18,7 +18,7 @@ process_data.generate_encrypted_test_data()
将在/tmp目录下生成对应于3个计算party的feature和label的加密数据文件,以后缀名区分属于不同party的数据。比如,`mnist2_feature.part0`表示属于party0的feature数据。
####2. 使用shell脚本启动demo
#### 2. 使用shell脚本启动demo
使用`run_standalone.sh`脚本,启动并运行demo,命令如下:
......@@ -30,7 +30,7 @@ bash run_standalone.sh mnist_demo.py
此外,在完成训练之后,demo会继续进行预测,并将预测密文结果保存到/tmp目录下的文件中,文件命名格式类似于步骤1中所述。
####3. 解密数据
#### 3. 解密数据
使用`process_data.py`脚本中的`decrypt_data_to_file()`,将保存的密文预测结果进行解密,并且将解密得到的明文预测结果保存到指定文件中。例如,将下面的内容写到一个`decrypt_save.py`脚本中,然后`python decrypt_save.py`,将把明文预测结果保存在`mpc_label`文件中。
......@@ -51,19 +51,19 @@ fi
###二. 多机运行
### 二. 多机运行
####1. 准备数据
#### 1. 准备数据
数据方对数据进行加密处理。具体操作和单机运行中的准备数据步骤一致。
####2. 分发数据
#### 2. 分发数据
按照后缀名,将步骤1中准备好的数据分别发送到对应的计算party的/tmp目录下。比如,使用scp命令,将
`mnist2_feature.part0``mnist2_label.part0`发送到party0的/tmp目录下。
####3. 计算party修改mnist_demo.py脚本
#### 3. 计算party修改mnist_demo.py脚本
各计算party根据自己的机器环境,将脚本如下内容中的`localhost`修改为自己的IP地址:
......@@ -71,7 +71,7 @@ fi
pfl_mpc.init("aby3", int(role), "localhost", server, int(port))
```
####4. 各计算party启动demo
#### 4. 各计算party启动demo
**注意**:运行需要用到redis服务。为了确保redis中已保存的数据不会影响demo的运行,请在各计算party启动demo之前,使用如下命令清空redis。其中,REDIS_BIN表示redis-cli可执行程序,SERVER和PORT分别表示redis server的IP地址和端口号。
......@@ -91,7 +91,7 @@ $PYTHON_EXECUTABLE mnist_demo.py $PARTY_ID $SERVER $PORT
**注意**:再次启动运行demo之前,请先将上次在`/tmp`保存的prediction文件删除,以免影响本次密文数据的恢复结果。
####5. 解密预测数据
#### 5. 解密预测数据
各计算party将`/tmp`目录下的`mnist_output_prediction.part`文件发送到数据方的/tmp目录下。数据方使用`process_data.py`脚本中的`decrypt_data_to_file()`,将密文预测结果进行解密,并且将解密得到的明文预测结果保存到指定文件中。例如,将下面的内容写到一个`decrypt_save.py`脚本中,然后`python decrypt_save.py`,将把明文预测结果保存在`mpc_label`文件中。
......
##Instructions for PaddleFL-MPC UCI Housing Demo
## Instructions for PaddleFL-MPC UCI Housing Demo
([简体中文](./README_CN.md)|English)
This document introduces how to run UCI Housing demo based on Paddle-MPC, which has two ways of running, i.e., single machine and multi machines.
###1. Running on Single Machine
### 1. Running on Single Machine
####(1). Prepare Data
#### (1). Prepare Data
Generate encrypted data utilizing `generate_encrypted_data()` in `process_data.py` script. For example, users can write the following code into a python script named `prepare.py`, and then run the script with command `python prepare.py`.
......@@ -17,7 +17,7 @@ process_data.generate_encrypted_data()
Encrypted data files of feature and label would be generated and saved in `/tmp` directory. Different suffix names are used for these files to indicate the ownership of different computation parties. For instance, a file named `house_feature.part0` means it is a feature file of party 0.
####(2). Launch Demo with A Shell Script
#### (2). Launch Demo with A Shell Script
Launch demo with the `run_standalone.sh` script. The concrete command is:
......@@ -48,17 +48,17 @@ fi
###2. Running on Multi Machines
### 2. Running on Multi Machines
####(1). Prepare Data
#### (1). Prepare Data
Data owner encrypts data. Concrete operations are consistent with “Prepare Data” in “Running on Single Machine”.
####(2). Distribute Encrypted Data
#### (2). Distribute Encrypted Data
According to the suffix of file name, distribute encrypted data files to `/tmp ` directories of all 3 computation parties. For example, send `house_feature.part0` and `house_label.part0` to `/tmp` of party 0 with `scp` command.
####(3). Modify uci_housing_demo.py
#### (3). Modify uci_housing_demo.py
Each computation party makes the following modifications on `uci_housing_demo.py` according to the environment of machine.
......@@ -82,7 +82,7 @@ Each computation party makes the following modifications on `uci_housing_demo.py
process_data.load_decrypt_data("/tmp/uci_prediction", (BATCH_SIZE,))
```
####(4). Launch Demo on Each Party
#### (4). Launch Demo on Each Party
**Note** that Redis service is necessary for demo running. Remember to clear the cache of Redis server before launching demo on each computation party, in order to avoid any negative influences caused by the cached records in Redis. The following command can be used for clear Redis, where REDIS_BIN is the executable binary of redis-cli, SERVER and PORT represent the IP and port of Redis server respectively.
......@@ -102,7 +102,7 @@ Similarly, training loss with cypher text format would be printed on the screen
**Note** that remember to delete the loss and precidtion files in `/tmp` directory generated in last running, in case of any influence on the decrypted results of current running.
####(5). Decrypt Loss and Prediction Data
#### (5). Decrypt Loss and Prediction Data
Each computation party sends `uci_loss.part` and `uci_prediction.part` files in `/tmp` directory to the `/tmp` directory of data owner. Data owner decrypts and gets the plain text of loss and predictions with ` load_decrypt_data()` in `process_data.py`.
......
##PaddleFL-MPC UCI Housing Demo运行说明
## PaddleFL-MPC UCI Housing Demo运行说明
(简体中文|[English](./README.md))
本示例介绍基于PaddleFL-MPC进行UCI房价预测模型训练和预测的使用说明,分为单机运行和多机运行两种方式。
###一. 单机运行
### 一. 单机运行
####1. 准备数据
#### 1. 准备数据
使用`process_data.py`脚本中的`generate_encrypted_data()`产生加密数据,比如将如下内容写到一个`prepare.py`脚本中,然后`python prepare.py`
......@@ -17,7 +17,7 @@ process_data.generate_encrypted_data()
将在/tmp目录下生成对应于3个计算party的feature和label的加密数据文件,以后缀名区分属于不同party的数据。比如,`house_feature.part0`表示属于party0的feature数据。
####2. 使用shell脚本启动demo
#### 2. 使用shell脚本启动demo
使用`run_standalone.sh`脚本,启动并运行demo,命令如下:
......@@ -48,19 +48,19 @@ fi
###二. 多机运行
### 二. 多机运行
####1. 准备数据
#### 1. 准备数据
数据方对数据进行加密处理。具体操作和单机运行中的准备数据步骤一致。
####2. 分发数据
#### 2. 分发数据
按照后缀名,将步骤1中准备好的数据分别发送到对应的计算party的/tmp目录下。比如,使用scp命令,将
`house_feature.part0``house_label.part0`发送到party0的/tmp目录下。
####3. 计算party修改uci_housing_demo.py脚本
#### 3. 计算party修改uci_housing_demo.py脚本
各计算party根据自己的机器环境,对uci_housing_demo.py做如下改动:
......@@ -84,7 +84,7 @@ fi
process_data.load_decrypt_data("/tmp/uci_prediction", (BATCH_SIZE,))
```
####4. 各计算party启动demo
#### 4. 各计算party启动demo
**注意**:运行需要用到redis服务。为了确保redis中已保存的数据不会影响demo的运行,请在各计算party启动demo之前,使用如下命令清空redis。其中,REDIS_BIN表示redis-cli可执行程序,SERVER和PORT分别表示redis server的IP地址和端口号。
......@@ -104,7 +104,7 @@ $PYTHON_EXECUTABLE uci_housing_demo.py $PARTY_ID $SERVER $PORT
**注意**:再次启动运行demo之前,请先将上次在`/tmp`保存的loss和prediction文件删除,以免影响本次密文数据的恢复结果。
####5. 数据方解密loss和prediction
#### 5. 数据方解密loss和prediction
各计算party将`/tmp`目录下的`uci_loss.part``uci_prediction.part`文件发送到数据方的/tmp目录下。数据方使用process_data.py脚本中的load_decrypt_data()解密恢复出loss数据和prediction数据。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册