提交 538d0bfd 编写于 作者: J jhjiangcs

improve doc.

上级 8468db4b
......@@ -4,13 +4,13 @@
### 1. Introduction
Users can decrypt encrypted model with Paddle-MPC. The decrypted model can be used for training and prediction.
User can decrypt encrypted model (three model shares) with Paddle-MPC. The decrypted model can be used for training and prediction.
### 2. Usages
We will show how to decrypt prediction model.
How to decrypt and use prediction model:
1. **Decrypt Model**Users decrypt encryped model with api `aby3.decrypt_model`.
1. **Decrypt Model**user decrypts encryped model with api `aby3.decrypt_model`.
```python
aby3.decrypt_model(mpc_model_dir=mpc_model_dir,
......@@ -19,9 +19,9 @@ We will show how to decrypt prediction model.
plain_model_filename=paddle_model_filename)
```
2. **Predict**Users can predict plaintext data with decrypted model.
2. **Predict**user predicts plaintext data with decrypted model.
1) User loads decrypted model with api `fluid.io.load_inference_model`.
1) Load decrypted model with api `fluid.io.load_inference_model`.
```python
infer_prog, feed_names, fetch_targets = fluid.io.load_inference_model(executor=exe,
......@@ -29,7 +29,7 @@ We will show how to decrypt prediction model.
model_filename=paddle_model_filename)
```
2) User predict plaintext data with decrypted model.
2) Predict plaintext data with decrypted model.
```python
results = exe.run(infer_prog,
......@@ -37,3 +37,6 @@ We will show how to decrypt prediction model.
fetch_list=fetch_targets)
```
### 3. Demo
Script `decrypt_inference_model.py` shows model decryption and prediction. Note that, encryption model should be saved in specified directory before running the script. Script `../model_encryption/predict/train_and_encrypt_model.py` can be used to generate encryption model.
......@@ -4,19 +4,15 @@
### 1. 介绍
基于paddle-mpc提供的功能,用户可以实现对MPC密文模型的解密,得到明文模型。具体地,模型解密可以满足用户对于明文模型的需求:在从各方获取密文模型之后,通过解密得到最终的明文模型,该明文模型和paddle模型的功能完全一致。
基于paddle-mpc提供的功能,用户可以实现对MPC密文模型的解密,得到明文模型,然后可以使用明文模型进行再训练/预测。具体地,用户从各方获取密文模型(基于多方训练/更新得到的密文模型)之后,通过调用解密接口可以得到明文模型,该明文模型和paddle模型的功能完全一致。
### 2. 使用场景
### 2. 使用方法
基于多方训练、更新得到的密文模型,解密恢复出完整的明文模型。该明文模型可用于继续训练和预测。
### 3. 使用方法
由于针对训练、更新和预测模型的解密步骤基本是一致的,所以这里以预测模型的解密为例,介绍模型解密的主要使用步骤。
由于针对训练、更新和预测模型的解密步骤基本是一致的,所以这里以预测模型的解密为例,介绍模型解密使用的主要步骤。
1. **解密模型**:模型解密需求方从各方获取保存的密文预测模型(即模型分片),使用paddle-mpc提供的模型解密接口`aby3.decrypt_model`解密恢复出明文预测模型。
假设获取到的三个密文模型分片存放`mpc_model_dir`目录下,使用`aby3.decrypt_model`进行解密
假设获取到的三个密文模型分片存放`mpc_model_dir`目录,使用`aby3.decrypt_model`进行解密,分别指定密文模型的路径和名字,明文模型的存放路径和名字
```python
aby3.decrypt_model(mpc_model_dir=mpc_model_dir,
......@@ -25,9 +21,9 @@
plain_model_filename=paddle_model_filename)
```
2. **预测**:使用解密后的预测模型对输入的待预测数据进行预测,输出预测的结果。
2. **预测**:使用解密后的预测模型对待预测的数据进行预测,输出预测结果。
该步骤同paddle预测模型的使用方法一致,首先使用`fluid.io.load_inference_model`加载预测模型:
该步骤同paddle预测模型的使用方法一致,首先使用`fluid.io.load_inference_model`加载明文预测模型:
```python
infer_prog, feed_names, fetch_targets = fluid.io.load_inference_model(executor=exe,
......@@ -43,7 +39,7 @@
fetch_list=fetch_targets)
```
### 4. 使用示例
### 3. 使用示例
提供了对UCI Housing房价预测模型进行解密并使用的示例,可直接运行`decrypt_inference_model.py`脚本得到预测结果。**需要注意的是**`decrypt_inference_model.py`脚本中待解密的模型设置为了`model_encryption/predict/predict.py`脚本内指定的模型,因此,执行脚本前请确保对应路径下已经保存了密文预测模型。
脚本`decrypt_and_inference.py`提供了对UCI Housing房价预测模型进行解密并使用的示例,可直接运行`decrypt_inference_model.py`脚本得到预测结果。**需要注意的是**`decrypt_inference_model.py`脚本中待解密的模型设置为`../model_encryption/predict/train_and_encrypt_model.py`脚本内指定的模型,因此,执行脚本前请确保对应路径下已经存在密文预测模型。
......@@ -4,7 +4,7 @@
### 1. Introduction
This document introduces how to run encrypt PaddlePaddle's model, then train or update encrypted model, or predict with encrypted model. Model encryption is suitable for protecting user data and model.
This document introduces how to run encrypt PaddlePaddle model, then train or update encrypted model, or predict encrypted data with encrypted model. Model encryption is suitable for protecting training/prediction data and model.
### 2. Scenarios
......@@ -12,15 +12,15 @@ Model encryption demo contains three scenarios:
* **Encrypt Model and Train**
Each party loads PaddlePadlde model and then encrypts it. Each party feeds the encrypted data to train the encrypted model. Each party can get one share for the encrypted model. PaddlePaddle model can be reconstructed with three encrypted model shares.
Each party loads PaddlePadlde model and encrypts it. Each party feeds the encrypted data to train the encrypted model. Each party can get one share for the encrypted model. PaddlePaddle model can be reconstructed with three encrypted model shares.
* **Encrypt Pre-trained Model and Update**
Pre-trained model is encryption and distributed to multipel parties. All parties update the encrypted model by feeding encrypted data. PaddlePaddle model can be reconstructed with three encrypted model shares.
Pre-trained model is encryption and distributed to multipel parties. Parties update the encrypted model with encrypted data. PaddlePaddle model can be reconstructed with three encrypted model shares.
* **Encrypt Pre-trained Model and Predict**
Pre-trained model is encryption and distributed to multipel parties. All parties predict encrypted data with encrypted model. Prediction ouput can be reconstructed with three encrypted prediction shares.
Pre-trained model is encryption and distributed to multipel parties. Parties predict encrypted data with the encrypted model. Prediction output can be reconstructed with three encrypted prediction output shares.
### 3. Usage
......@@ -28,9 +28,9 @@ Pre-trained model is encryption and distributed to multipel parties. All parties
<img src='images/model_training.png' width = "500" height = "550" align="middle"/>
This figure shows the model encryption training with Paddle-MPC.
This figure shows model encryption and training with Paddle-MPC.
1. **Load Model**: Users init mpc context with mpc_init OP. Then, users load or define PaddlePaddle network.
1). **Load PaddlePaddle Model**: Users init mpc context with mpc_init OP, then load or define PaddlePaddle network.
```python
pfl_mpc.init("aby3", role, ip, server, port)
......@@ -38,13 +38,13 @@ This figure shows the model encryption training with Paddle-MPC.
exe.run(fluid.default_startup_program())
```
2. **Transpile(Encrypt) Model**: Users use api `aby3.transpile` encrypt PaddlePaddle model.
2). **Transpile(Encrypt) Model**: Users use api `aby3.transpile` to encrypt curent default PaddlePaddle model.
```python
aby3.transpile()
```
3. **Train Model**: Users train encrypted model with encrypted data.
3). **Train Model**: Users train encrypted model with encrypted data.
```python
for epoch_id in range(epoch_num):
......@@ -52,7 +52,7 @@ This figure shows the model encryption training with Paddle-MPC.
mpc_loss = exe.run(feed=mpc_sample, fetch_list=[loss.name])
```
4. **Save Model**:Users save encrypted model using `aby3.save_trainable_model`.
4). **Save Model**:Users save encrypted model using `aby3.save_trainable_model`.
```python
aby3.save_trainable_model(exe=exe,
......@@ -60,7 +60,7 @@ This figure shows the model encryption training with Paddle-MPC.
model_filename=model_filename)
```
5. **Decrypt Model**:Users can decrypt model with the model shares.
5). **Decrypt Model**:PaddlePaddle model can be reconstructed with three model shares (encrypted model).
#### 3.2 Update Model
......@@ -68,9 +68,9 @@ This figure shows the model encryption training with Paddle-MPC.
This figure shows how to update pre-trained model with Paddle-MPC.
1. **Pre-train Model**: Users train PaddlePaddle model with plaintext data.
1). **Pre-train Model**: PaddlePaddle model is trained with plaintext data.
2. **Encrypt Model**: Users encrypt pre-trained model with api `aby3.encrypt_model` and distribute model shares to other users.
2). **Encrypt Model**: User encrypts pre-trained model with api `aby3.encrypt_model` and distributes three model shares to three parties.
```python
# Step 1. Load pre-trained model.
......@@ -83,7 +83,7 @@ This figure shows how to update pre-trained model with Paddle-MPC.
model_filename=model_filename)
```
3. **Update Model**:Users init mpc context with mpc_init OP, then load encrypted model with `aby3.load_mpc_model`. Users update the encrypted model with encrypted data.
3). **Update Model**:Users init mpc context with mpc_init OP, then load encrypted model with `aby3.load_mpc_model`. Users update the encrypted model with encrypted data.
```python
# Step 1. initialize MPC environment and load MPC model into
......@@ -99,19 +99,19 @@ This figure shows how to update pre-trained model with Paddle-MPC.
mpc_loss = exe.run(feed=mpc_sample, fetch_list=[loss.name])
```
4. **Decrypt Model**:Users can decrypt model with the model shares.
4). **Decrypt Model**:User can decrypt model with three model shares.
#### 3.3 Predict Model
<img src='images/model_infer.png' width = "500" height = "380" align="middle"/>
This figure shows how to predict with encrypted model.
This figure shows how to predict encryted data with encrypted model.
1. **Train Model**:Users train PaddlePaddle model with plaintext data.
1). **Train Model**:User trains PaddlePaddle model with plaintext data.
2. **Encrypt Model**: Users encrypt model with api `aby3.encrypt_model` and distribute model shares to other users. The api is same with `Update Model`.
2). **Encrypt Model**: User encrypts model with api `aby3.encrypt_model` and distributes model shares to three users. The api is same with `Update Model`.
3. **Predict Model**: Users initialize mpc context with `mpc_init OP`, then load encrypted model with api `aby3.load_mpc_model`. Users predict encryped data with encryted model.
3). **Predict/Infer**: Users initialize mpc context with `mpc_init OP`, then load encrypted model with api `aby3.load_mpc_model`. Users predict encryped data with encryted model.
```python
# Step 1. initialize MPC environment and load MPC model to predict
......@@ -128,22 +128,11 @@ This figure shows how to predict with encrypted model.
f.write(np.array(prediction).tostring())
```
4. **Decrypt Model**:Users can decrypt model with the model shares.
4. **Decrypt Model**:User can decrypt model with the model shares.
### 4. Usage Demo
#### 4.1 Train Model
Instructions for model encryption and training with PaddleFL-MPC using UCI Housing dataset: [Here](./train).
#### 4.2 Update Model
Instructions for pre-trained model encryption and update with Paddle-MPC using UCI Housing dataset: [Here](./update).
#### 4.3 Predict Model
Instructions for pre-trained model encryption and prediction with Paddle-MPC using UCI Housing dataset: [Here](./predict).
**Train Model**: Instructions for model encryption and training with PaddleFL-MPC using UCI Housing dataset: [Here](./train).
**Update Model**: Instructions for pre-trained model encryption and update with Paddle-MPC using UCI Housing dataset: [Here](./update).
**Predict Model**: Instructions for pre-trained model encryption and prediction with Paddle-MPC using UCI Housing dataset: [Here](./predict).
......@@ -4,7 +4,7 @@
### 1. 介绍
基于Paddle-MPC提供的功能,用户可以实现对明文PaddlePaddle模型的加密,然后根据具体需求在加密的模型上使用密文数据进行模型的训练、更新或预测。因此,模型加密可以用于同时保护用户训练数据和模型的场景。
基于Paddle-MPC提供的功能,用户可以实现对明文PaddlePaddle模型的加密,然后根据具体需求在加密的模型上使用密文数据进行模型的训练、更新或预测。因此,模型加密可以用于同时保护用户训练数据和模型的场景。
### 2. 使用场景
......@@ -12,7 +12,7 @@
* **模型加密后训练**
多方用户使用各自数据联合进行已有模型的训练。在该场景下,各方用户可直接加载模型库中的网络模型或自定义的网络模型(未训练的模型program)并对模型加密,各方使用密文训练数据联合进行密文模型的训练和保存。训练完成后,各方只拥有密文模型,即明文模型的分片,在需要时可以基于模型分片解密恢复出完整的明文模型。
多方用户使用各自数据联合进行已有模型的训练。在该场景下,各方用户可直接加载模型库中的网络模型或自定义的网络模型并对模型加密,各方使用密文训练数据联合进行密文模型的训练和保存。训练完成后,各方只拥有密文模型,即明文模型的分片,在需要时可以基于模型分片解密恢复出完整的明文模型。
* **预训练模型加密后再更新**
......@@ -28,9 +28,9 @@
<img src='images/model_training.png' width = "500" height = "550" align="middle"/>
使用paddle-mpc进行模型加密训练的过程示意图如上,主要方法步骤如下:
使用Paddle-MPC进行模型加密训练的过程示意图如上,主要方法步骤如下:
1. **加载模型**:各方用户使用mpc_init OP初始化MPC环境,然后直接加载模型库中的网络模型或自定义的网络模型并完成参数的初始化。具体API用例为:
1). **加载明文模型**:各方用户使用mpc_init OP初始化MPC环境,然后直接加载模型库中的网络模型或自定义的网络模型并完成参数的初始化。具体API用例为:
```python
pfl_mpc.init("aby3", role, ip, server, port)
......@@ -38,13 +38,13 @@
exe.run(fluid.default_startup_program())
```
2. **模型转换**(加密):各方使用paddle-mpc提供的模型转换接口`aby3.transpile`,将明文模型转换(加密)成密文模型。具体API用例为:
2). **模型转换**(加密):各方使用Paddle-MPC提供的模型转换接口`aby3.transpile`,将明文模型转换(加密)成密文模型。具体API用例为:
```python
aby3.transpile()
```
3. **联合训练**:各方使用密文训练数据联合进行密文模型的训练。具体API用例为:
3). **联合训练**:各方使用密文训练数据联合进行密文模型的训练。具体API用例为:
```python
for epoch_id in range(epoch_num):
......@@ -52,7 +52,7 @@
mpc_loss = exe.run(feed=mpc_sample, fetch_list=[loss.name])
```
4. **模型保存**:训练完成后,各方使用`aby3.save_trainable_model`接口保存训练好的密文模型。具体API用例为:
4). **模型保存**:训练完成后,各方使用`aby3.save_trainable_model`接口保存训练好的密文模型。具体API用例为:
```python
aby3.save_trainable_model(exe=exe,
......@@ -60,17 +60,17 @@
model_filename=model_filename)
```
5. **模型解密**:如有需要,模型解密需求方从各方获取保存的密文模型,使用paddle-mpc提供的模型解密功能解密恢复出明文模型。具体可参考`model_decryption`目录中的介绍。
5). **模型解密**:如有需要,模型解密需求方从各方获取保存的密文模型,使用Paddle-MPC提供的模型解密功能解密恢复出明文模型。具体可参考`model_decryption`目录中的介绍。
#### 3.2 模型更新
<img src='images/model_updating.png' width = "500" height = "380" align="middle"/>
使用paddle-mpc进行模型加密更新的过程示意图如上,主要方法步骤如下:
使用Paddle-MPC进行模型加密更新的过程示意图如上,主要方法步骤如下:
1. **模型预训练**:使用明文数据完成明文模型的预训练,得到预训练模型并保存。该步骤由预训练模型拥有方执行,是进行模型加密前的预训练操作。
1). **模型预训练**:使用明文数据完成明文模型的预训练,得到预训练模型并保存。该步骤由预训练模型拥有方执行,是进行模型加密前的预训练操作。
2. **模型加密**:预训练模型拥有方使用paddle-mpc提供的模型加密接口`aby3.encrypt_model`将预训练模型进行加密。加密得到的三个密文模型(即明文模型分片)分别发送给三个模型更新方保存。具体API用例为:
2). **模型加密**:预训练模型拥有方使用Paddle-MPC提供的模型加密接口`aby3.encrypt_model`将预训练模型进行加密。加密得到的三个密文模型(即明文模型分片)分别发送给三个模型更新方保存。具体API用例为:
```python
# Step 1. Load pre-trained model.
......@@ -83,7 +83,7 @@
model_filename=model_filename)
```
3. **联合更新**:更新模型的三方使用mpc_init OP初始化MPC环境,然后使用paddle-mpc提供的模型加载接口`aby3.load_mpc_model`加载保存的密文模型,基于密文模型和密文数据进行密文模型的更新并保存更新完成的密文模型。具体API用例为:
3). **联合更新**:更新模型的三方使用mpc_init OP初始化MPC环境,然后使用Paddle-MPC提供的模型加载接口`aby3.load_mpc_model`加载保存的密文模型,基于密文模型和密文数据进行密文模型的更新并保存更新后的密文模型。具体API用例为:
```python
# Step 1. initialize MPC environment and load MPC model into
......@@ -99,19 +99,19 @@
mpc_loss = exe.run(feed=mpc_sample, fetch_list=[loss.name])
```
4. **模型解密**:如有需要,模型解密需求方从各方获取保存的密文模型,使用paddle-mpc提供的模型解密功能解密恢复出明文模型。
4). **模型解密**:如有需要,模型解密需求方从各方获取保存的密文模型,使用Paddle-MPC提供的模型解密功能解密恢复出明文模型。
#### 3.3 模型预测
<img src='images/model_infer.png' width = "500" height = "380" align="middle"/>
使用paddle-mpc进行模型加密预测的过程示意图如上,主要方法步骤如下:
使用Paddle-MPC进行模型加密预测的过程示意图如上,主要方法步骤如下:
1. **模型训练**:使用明文数据完成明文预测模型的训练和保存。该步骤由预测模型拥有方执行。
1). **模型训练**:使用明文数据完成明文预测模型的训练和保存。该步骤由预测模型拥有方执行。
2. **模型加密**:预测模型拥有方使用paddle-mpc提供的模型加密接口`aby3.encrypt_model`将预测模型进行加密。加密得到的三个密文模型(即明文模型分片)分别发送给三个预测方保存。具体API用例同模型更新中的介绍。
2). **模型加密**:预测模型拥有方使用Paddle-MPC提供的模型加密接口`aby3.encrypt_model`将预测模型进行加密。加密得到的三个密文模型(即明文模型分片)分别发送给三个预测方保存。具体API用例同模型更新中的介绍。
3. **联合预测**:执行预测的三方使用mpc_init OP初始化MPC环境,然后使用paddle-mpc提供的模型加载接口`aby3.load_mpc_model`加载密文预测模型,基于密文预测模型和密文数据进行预测并保存密文预测结果。具体API用例为:
3). **联合预测**:执行预测的三方使用mpc_init OP初始化MPC环境,然后使用Paddle-MPC提供的模型加载接口`aby3.load_mpc_model`加载密文预测模型,基于密文预测模型和密文数据进行预测并保存密文预测结果。具体API用例为:
```python
# Step 1. initialize MPC environment and load MPC model to predict
......@@ -128,21 +128,13 @@
f.write(np.array(prediction).tostring())
```
4. **结果解密**:预测结果请求方从各方获取保存的密文预测结果,使用paddle-mpc提供的数据解密功能解密恢复出明文预测结果。
4). **结果解密**:预测结果请求方从各方获取保存的密文预测结果,使用Paddle-mpc提供的数据解密功能解密恢复出明文预测结果。
### 4. 使用示例
#### 4.1 模型训练
使用UCI Housing房价预测模型加密训练的示例,请见[这里](./train)
#### 4.2 模型更新
使用UCI Housing房价预测模型加密更新的示例,请见[这里](./update)
#### 4.3 模型预测
使用UCI Housing房价预测模型加密预测的示例,请见[这里](./predict)
**模型训练**: 使用UCI Housing房价预测模型加密训练的示例,请见[这里](./train)
**模型更新**: 使用UCI Housing房价预测模型加密更新的示例,请见[这里](./update)
**模型预测**: 使用UCI Housing房价预测模型加密预测的示例,请见[这里](./predict)
......
## Instructions for pre-trained model encryption and prediction with Paddle-MPC
## Instructions for Pre-trained Model Encryption and Prediction with Paddle-MPC
([简体中文](./README_CN.md)|English)
This document introduces how to encrypt pre-trained plaintext model and predict based it on Paddle-MPC.
This document introduces how to encrypt pre-trained plaintext model and predict encrypted data with the encrypted model based on Paddle-MPC.
### 1. Train PaddlePaddle Model, Encrypt, and Save
###1. Train PaddlePaddle Model, Encrypt, and Save
Train plaintext PaddlePaddle model, encrypt, and save with the following script.
Train plaintext PaddlePaddle model, encrypt, and save it with the following script.
```bash
python train_and_encrypt_model.py
```
###2. Prepare Data
### 2. Prepare Data
Run script `../process_data.py` to generate encrypted training and testing data.
Run script `../process_data.py` to generate encrypted prediction input data.
###3. Predict with MPC Model
### 3. Predict with MPC Model
Predict mpc model with the following script.
Predict encrypted data using encrypted model with the following script.
```bash
bash run_standalone.sh predict_with_mpc_model.py
```
###4. Decrypt Prediction Data
### 4. Decrypt Prediction Output Data
Decrypt predition data.
Decrypt predition output data with the following script.
```bash
python decrypt_mpc_prediction.py
......
......@@ -2,7 +2,7 @@
(简体中文|[English](./README.md))
###1. 训练明文模型并加密保存
### 1. 训练明文模型并加密保存
使用如下命令完成明文模型的训练、加密和保存:
......@@ -10,11 +10,11 @@
python train_and_encrypt_model.py
```
###2. 准备用于预测的加密数据
### 2. 准备用于预测的加密数据
执行脚本`../process_data.py`完成模型更新所需数据的加密处理
执行脚本`../process_data.py`加密待预测的数据
###3. 加密预测
### 3. 加密预测
使用如下命令完成密文模型预测:
......@@ -22,7 +22,7 @@ python train_and_encrypt_model.py
bash run_standalone.sh predict_with_mpc_model.py
```
###4. 解密loss数据验证密文模型预测过程
### 4. 解密loss数据验证密文模型预测过程
使用如下命令对保存的预测结果进行解密查看:
......
## Instructions for PaddleFL-MPC model encryption and training
## Instructions for PaddleFL-MPC Model Encryption and Training
([简体中文](./README_CN.md)|English)
This document introduces how to encrypt plaintext model and training based on Paddle-MPC.
This document introduces how to encrypt plaintext model and train the encrypted model based on Paddle-MPC.
###1. Prepare Data
### 1. Prepare Data
Run script `../process_data.py` to generate encrypted training and testing data.
###2. Encrypt Model, Train, and Save
### 2. Encrypt Model, Train, and Save
Encrypt plaintext PaddlePaddle model, train the model, and save it with the following script.
Encrypt plaintext PaddlePaddle model, train the encrypted model, and save the trained encrypted model with the following script.
```bash
bash run_standalone.sh encrypt_and_train_model.py
```
###3. Decrypt Loss Data
### 3. Decrypt Loss Data
Decrypt the loss data to test the correctness of mpc training by running the following script.
Decrypt the loss data to test the correctness of mpc training with the following script.
```bash
python decrypt_mpc_loss.py
......
......@@ -2,21 +2,21 @@
(简体中文|[English](./README.md))
本示例介绍基于PaddleFL-MPC进行明文模型加密后再进行训练的使用说明。
本示例简单介绍了基于PaddleFL-MPC对明文模型加密后再训练的使用说明。
###1. 准备加密数据
### 1. 准备加密数据
执行脚本`../process_data.py`完成训练数据的加密处理
执行脚本`../process_data.py`完成训练数据的加密处理
###2. 训练明文模型并加密保存
### 2. 训练明文模型并加密保存
使用如下命令完成模型的加密、密文模型的训练与保存:
使用如下命令完成模型的加密、训练与保存:
```bash
bash run_standalone.sh encrypt_and_train_model.py
```
###3. 解密loss数据验证密文模型训练过程
### 3. 解密loss数据验证密文模型训练过程正确性
使用如下命令对训练过程中保存的loss数据进行解密查看,验证训练的正确性:
......
## Instructions for pre-trained model encryption and update with Paddle-MPC
## Instructions for Pre-trained Model Encryption and Update with Paddle-MPC
([简体中文](./README_CN.md)|English)
This document introduces how to encrypt pre-trained plaintext model and update based it on Paddle-MPC.
This document introduces how to encrypt pre-trained plaintext model and update it based on Paddle-MPC.
###1. Train PaddlePaddle Model, Encrypt, and Save
### 1. Train PaddlePaddle Model, Encrypt, and Save
Train plaintext PaddlePaddle model, encrypt, and save with the following script.
......@@ -13,11 +12,11 @@ Train plaintext PaddlePaddle model, encrypt, and save with the following script.
python train_and_encrypt_model.py
```
###2. Prepare Data
### 2. Prepare Data
Run script `../process_data.py` to generate encrypted training and testing data.
Run script `../process_data.py` to generate encrypted training and testing data for updating encrypted model.
###3. Update MPC Model
### 3. Update MPC Model
Update mpc model with the following script.
......@@ -25,9 +24,9 @@ Update mpc model with the following script.
bash run_standalone.sh update_mpc_model.py
```
###4. Decrypt Loss Data
### 4. Decrypt Loss Data
Decrypt the loss data to test the correctness of mpc training by running the following script.
Decrypt the loss data to test the correctness of encrypted model updating by running the following script.
```bash
python decrypt_mpc_loss.py
......
......@@ -2,31 +2,31 @@
(简体中文|[English](./README.md))
本示例介绍基于PaddleFL-MPC对预训练对明文模型加密后再进行训练更新的使用说明。
本示例介绍基于PaddleFL-MPC对预训练明文模型加密后再训练更新的使用说明。
###1. 训练明文模型并加密保存
### 1. 训练明文模型并加密保存
使用如下命令完成明文模型的训练、加密和保存:
使用如下命令训练明文模型并加密保存:
```bash
python train_and_encrypt_model.py
```
###2. 准备用于更新模型的加密数据
### 2. 准备用于更新模型的加密数据
执行脚本`../process_data.py`完成模型更新所需数据的加密处理
执行脚本`../process_data.py`生成更新模型所需的加密数据
###3. 更新密文模型
### 3. 更新密文模型
使用如下命令完成密文模型的训练与保存:
使用如下命令训练更新密文模型并保存:
```bash
bash run_standalone.sh update_mpc_model.py
```
###4. 解密loss数据验证密文模型更新过程
### 4. 解密loss数据验证密文模型更新过程的正确性
使用如下命令对更新过程中保存的loss数据进行解密查看:
使用如下命令对更新过程中保存的loss数据进行解密查看,验证更新过程的正确性
```bash
python decrypt_mpc_loss.py
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册