Skip to content
Snippets Groups Projects
Commit 7eb79703 authored by anzhengqi's avatar anzhengqi
Browse files

modify network wide&deep readme file

parent aad78cab
No related branches found
No related tags found
No related merge requests found
...@@ -61,13 +61,13 @@ Currently we support host-device mode with multi-dimensional partition parallel ...@@ -61,13 +61,13 @@ Currently we support host-device mode with multi-dimensional partition parallel
1. Clone the Code 1. Clone the Code
```bash ```bash
git clone https://gitee.com/mindspore/mindspore.git git clone https://gitee.com/mindspore/models.git
cd mindspore/model_zoo/official/recommend/wide_and_deep cd models/official/recommend/wide_and_deep
``` ```
2. Download the Dataset 2. Download the Dataset
> Please refer to [1] to obtain the download link > Please refer to [1](#dataset) to obtain the download link
```bash ```bash
mkdir -p data/origin_data && cd data/origin_data mkdir -p data/origin_data && cd data/origin_data
...@@ -86,13 +86,13 @@ python src/preprocess_data.py --data_path=./data/ --dense_dim=13 --slot_dim=26 ...@@ -86,13 +86,13 @@ python src/preprocess_data.py --data_path=./data/ --dense_dim=13 --slot_dim=26
Once the dataset is ready, the model can be trained and evaluated on the single device(Ascend) by the command as follows: Once the dataset is ready, the model can be trained and evaluated on the single device(Ascend) by the command as follows:
```bash ```bash
python train_and_eval.py --data_path=./data/mindrecord --dataset_type=mindrecord python train_and_eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend
``` ```
To evaluate the model, command as follows: To evaluate the model, command as follows:
```bash ```bash
python eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --ckpt_path=./ckpt/widedeep_train-15_2582.ckpt python eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend --ckpt_path=./ckpt/widedeep_train-15_2582.ckpt
``` ```
- Running on ModelArts (If you want to run in modelarts, please check the official documentation of [modelarts](https://support.huaweicloud.com/modelarts/), and you can start training as follows) - Running on ModelArts (If you want to run in modelarts, please check the official documentation of [modelarts](https://support.huaweicloud.com/modelarts/), and you can start training as follows)
...@@ -312,7 +312,7 @@ wget DATA_LINK ...@@ -312,7 +312,7 @@ wget DATA_LINK
tar -zxvf dac.tar.gz tar -zxvf dac.tar.gz
``` ```
> Please refer to [1] to obtain the download link > Please refer to [1](#dataset) to obtain the download link
2. Use this script to preprocess the data 2. Use this script to preprocess the data
...@@ -344,7 +344,7 @@ python src/preprocess_data.py --data_path=./syn_data/ --dense_dim=13 --slot_dim ...@@ -344,7 +344,7 @@ python src/preprocess_data.py --data_path=./syn_data/ --dense_dim=13 --slot_dim
To train and evaluate the model, command as follows: To train and evaluate the model, command as follows:
```python ```python
python train_and_eval.py python train_and_eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend
``` ```
### [SingleDevice For Cache Mode](#contents) ### [SingleDevice For Cache Mode](#contents)
...@@ -352,7 +352,7 @@ python train_and_eval.py ...@@ -352,7 +352,7 @@ python train_and_eval.py
To train and evaluate the model, command as follows: To train and evaluate the model, command as follows:
```python ```python
python train_and_eval.py --vocab_size=200000 --vocab_cache_size=160000 python train_and_eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend --sparse=True --vocab_size=200000 --vocab_cache_size=160000
``` ```
### [Distribute Training](#contents) ### [Distribute Training](#contents)
...@@ -402,15 +402,15 @@ bash run_parameter_server_train.sh RANK_SIZE EPOCHS DATASET RANK_TABLE_FILE SERV ...@@ -402,15 +402,15 @@ bash run_parameter_server_train.sh RANK_SIZE EPOCHS DATASET RANK_TABLE_FILE SERV
To evaluate the model, command as follows: To evaluate the model, command as follows:
```python ```python
python eval.py python eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend --ckpt_path=./ckpt/widedeep_train-15_2582.ckpt
``` ```
## Inference Process ## Inference Process
### [Export MindIR](#contents) ### [Export MindIR](#contents)
```shell ```python
python export.py --ckpt_file [CKPT_PATH] --file_name [FILE_NAME] --file_format [FILE_FORMAT] python export.py --ckpt_file [CKPT_PATH] --file_name [FILE_NAME] --device_target [DEVICE_TARGET] --file_format [FILE_FORMAT]
``` ```
The ckpt_file parameter is required, The ckpt_file parameter is required,
...@@ -448,7 +448,7 @@ Inference result is saved in current path, you can find result like this in acc. ...@@ -448,7 +448,7 @@ Inference result is saved in current path, you can find result like this in acc.
| Resource | Ascend 910; OS Euler2.8 | Tesla V100-PCIE 32G | Ascend 910; OS Euler2.8 | Ascend 910; OS Euler2.8 | | Resource | Ascend 910; OS Euler2.8 | Tesla V100-PCIE 32G | Ascend 910; OS Euler2.8 | Ascend 910; OS Euler2.8 |
| Uploaded Date | 07/05/2021 (month/day/year) | 07/05/2021 (month/day/year) | 07/05/2021 (month/day/year) | 07/05/2021 (month/day/year) | | Uploaded Date | 07/05/2021 (month/day/year) | 07/05/2021 (month/day/year) | 07/05/2021 (month/day/year) | 07/05/2021 (month/day/year) |
| MindSpore Version | 1.3.0 | 1.3.0 | 1.3.0 | 1.3.0 | | MindSpore Version | 1.3.0 | 1.3.0 | 1.3.0 | 1.3.0 |
| Dataset | [1] | [1] | [1] | [1] | | Dataset | [1](#dataset) | [1](#dataset) | [1](#dataset) | [1](#dataset) |
| Training Parameters | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | | Training Parameters | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 |
| Optimizer | FTRL,Adam | FTRL,Adam | FTRL,Adam | FTRL,Adam | | Optimizer | FTRL,Adam | FTRL,Adam | FTRL,Adam | FTRL,Adam |
| Loss Function | SigmoidCrossEntroy | SigmoidCrossEntroy | SigmoidCrossEntroy | SigmoidCrossEntroy | | Loss Function | SigmoidCrossEntroy | SigmoidCrossEntroy | SigmoidCrossEntroy | SigmoidCrossEntroy |
......
# 目录 # 目录
- [目录](#目录) - [目录](#目录)
- [Wide&Deep概述](#widedeep概述) - [Wide&Deep概述](#Wide&Deep概述)
- [模型架构](#模型架构) - [模型架构](#模型架构)
- [数据集](#数据集) - [数据集](#数据集)
- [环境要求](#环境要求) - [环境要求](#环境要求)
...@@ -64,13 +64,13 @@ Wide&Deep模型训练了宽线性模型和深度学习神经网络,结合了 ...@@ -64,13 +64,13 @@ Wide&Deep模型训练了宽线性模型和深度学习神经网络,结合了
1. 克隆代码。 1. 克隆代码。
```bash ```bash
git clone https://gitee.com/mindspore/mindspore.git git clone https://gitee.com/mindspore/models.git
cd mindspore/model_zoo/official/recommend/wide_and_deep cd models/official/recommend/wide_and_deep
``` ```
2. 下载数据集。 2. 下载数据集。
> 请参考[1]获得下载链接。 > 请参考[1](#数据集)获得下载链接。
```bash ```bash
mkdir -p data/origin_data && cd data/origin_data mkdir -p data/origin_data && cd data/origin_data
...@@ -89,13 +89,13 @@ python src/preprocess_data.py --data_path=./data/ --dense_dim=13 --slot_dim=26 ...@@ -89,13 +89,13 @@ python src/preprocess_data.py --data_path=./data/ --dense_dim=13 --slot_dim=26
数据集准备就绪后,即可在Ascend上单机训练和评估模型。 数据集准备就绪后,即可在Ascend上单机训练和评估模型。
```bash ```bash
python train_and_eval.py --data_path=./data/mindrecord --dataset_type=mindrecord python train_and_eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend
``` ```
按如下操作评估模型: 按如下操作评估模型:
```bash ```bash
python eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --ckpt_path=./ckpt/widedeep_train-15_2582.ckpt python eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend --ckpt_path=./ckpt/widedeep_train-15_2582.ckpt
``` ```
- 在ModelArts上运行(如果想在modelarts中运行,请查看【modelarts】官方文档(https://support.huaweicloud.com/modelarts/),如下开始训练即可) - 在ModelArts上运行(如果想在modelarts中运行,请查看【modelarts】官方文档(https://support.huaweicloud.com/modelarts/),如下开始训练即可)
...@@ -316,7 +316,7 @@ wget DATA_LINK ...@@ -316,7 +316,7 @@ wget DATA_LINK
tar -zxvf dac.tar.gz tar -zxvf dac.tar.gz
``` ```
> 从[1]获取下载链接。 > 从[1](#数据集)获取下载链接。
2. 使用此脚本预处理数据。 2. 使用此脚本预处理数据。
...@@ -348,7 +348,7 @@ python src/preprocess_data.py --data_path=./syn_data/ --dense_dim=13 --slot_dim ...@@ -348,7 +348,7 @@ python src/preprocess_data.py --data_path=./syn_data/ --dense_dim=13 --slot_dim
运行如下命令训练和评估模型: 运行如下命令训练和评估模型:
```bash ```bash
python train_and_eval.py python train_and_eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend
``` ```
### 单机训练缓存模式 ### 单机训练缓存模式
...@@ -356,7 +356,7 @@ python train_and_eval.py ...@@ -356,7 +356,7 @@ python train_and_eval.py
运行如下命令训练和评估模型: 运行如下命令训练和评估模型:
```bash ```bash
python train_and_eval.py --vocab_size=200000 --vocab_cache_size=160000 python train_and_eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend --sparse=True --vocab_size=200000 --vocab_cache_size=160000
``` ```
### 分布式训练 ### 分布式训练
...@@ -405,16 +405,8 @@ bash run_parameter_server_train.sh RANK_SIZE EPOCHS DATASET RANK_TABLE_FILE SERV ...@@ -405,16 +405,8 @@ bash run_parameter_server_train.sh RANK_SIZE EPOCHS DATASET RANK_TABLE_FILE SERV
运行如下命令评估模型: 运行如下命令评估模型:
```bash
python eval.py
```
## [Evaluation Process](#contents)
To evaluate the model, command as follows:
```python ```python
python eval.py python eval.py --data_path=./data/mindrecord --dataset_type=mindrecord --device_target=Ascend --ckpt_path=./ckpt/widedeep_train-15_2582.ckpt
``` ```
## 推理过程 ## 推理过程
...@@ -422,7 +414,7 @@ python eval.py ...@@ -422,7 +414,7 @@ python eval.py
### [导出MindIR](#contents) ### [导出MindIR](#contents)
```shell ```shell
python export.py --ckpt_file [CKPT_PATH] --file_name [FILE_NAME] --file_format [FILE_FORMAT] python export.py --ckpt_file [CKPT_PATH] --file_name [FILE_NAME] --device_target [DEVICE_TARGET] --file_format [FILE_FORMAT]
``` ```
参数ckpt_file为必填项, 参数ckpt_file为必填项,
...@@ -460,7 +452,7 @@ bash run_infer_310.sh [MINDIR_PATH] [DATASET_PATH] [DATA_TYPE] [NEED_PREPROCESS] ...@@ -460,7 +452,7 @@ bash run_infer_310.sh [MINDIR_PATH] [DATASET_PATH] [DATA_TYPE] [NEED_PREPROCESS]
| 资源 |Ascend 910;系统 Euler2.8 | Tesla V100-PCIE 32G | Ascend 910;系统 Euler2.8 | Ascend 910;系统 Euler2.8 | | 资源 |Ascend 910;系统 Euler2.8 | Tesla V100-PCIE 32G | Ascend 910;系统 Euler2.8 | Ascend 910;系统 Euler2.8 |
| 上传日期 | 2021-07-05 | 2021-07-05 | 2021-07-05 | 2021-07-05 | | 上传日期 | 2021-07-05 | 2021-07-05 | 2021-07-05 | 2021-07-05 |
| MindSpore版本 | 1.3.0 | 1.3.0 | 1.3.0 | 1.3.0 | | MindSpore版本 | 1.3.0 | 1.3.0 | 1.3.0 | 1.3.0 |
| 数据集 | [1] | [1] | [1] | [1] | | 数据集 | [1](#数据集) | [1](#数据集) | [1](#数据集) | [1](#数据集) |
| 训练参数 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | | 训练参数 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 | Epoch=15,<br />batch_size=16000 |
| 优化器 | FTRL,Adam | FTRL,Adam | FTRL,Adam | FTRL,Adam | | 优化器 | FTRL,Adam | FTRL,Adam | FTRL,Adam | FTRL,Adam |
| 损失函数 | Sigmoid交叉熵 | Sigmoid交叉熵 | Sigmoid交叉熵 | Sigmoid交叉熵 | | 损失函数 | Sigmoid交叉熵 | Sigmoid交叉熵 | Sigmoid交叉熵 | Sigmoid交叉熵 |
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"""Generate the synthetic data for wide&deep model training""" """Generate the synthetic data for wide&deep model training"""
import time import time
import numpy as np import numpy as np
from .model_utils.config import config from src.model_utils.config import config
def generate_data(output_path, label_dim, number_examples, dense_dim, slot_dim, vocabulary_size, random_slot_values): def generate_data(output_path, label_dim, number_examples, dense_dim, slot_dim, vocabulary_size, random_slot_values):
""" """
......
...@@ -18,7 +18,7 @@ import pickle ...@@ -18,7 +18,7 @@ import pickle
import collections import collections
import numpy as np import numpy as np
from mindspore.mindrecord import FileWriter from mindspore.mindrecord import FileWriter
from .model_utils.config import config from src.model_utils.config import config
class StatsDict(): class StatsDict():
"""preprocessed data""" """preprocessed data"""
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment