Skip to content

Commit 7bcd9ec

Browse files
authored
Merge pull request #443 from yinhaofeng/dead_chain
Dead chain
2 parents a167b70 + 64f680a commit 7bcd9ec

File tree

7 files changed

+30
-6
lines changed

7 files changed

+30
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ python -u tools/static_trainer.py -m models/rank/dnn/config.yaml # 静态图训
132132
* [自定义Reader](doc/custom_reader.md)
133133
* [自定义模型](doc/model_develop.md)
134134
* [yaml配置说明](doc/yaml.md)
135+
* [训练可视化](doc/visualization.md)
136+
* [在线Serving部署](doc/serving.md)
137+
* [python端预测库推理](doc/inference.md)
135138
* [Benchmark](doc/benchmark.md)
136139

137140
### FAQ

README_EN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ python -u tools/static_trainer.py -m models/rank/dnn/config.yaml # Training wit
126126
* [Custom Reader](doc/custom_reader.md)
127127
* [Custom Model](doc/model_develop.md)
128128
* [Configuration description of yaml](doc/yaml.md)
129+
* [Training visualization](doc/visualization.md)
130+
* [Serving](doc/serving.md)
131+
* [Python inference](doc/inference.md)
129132
* [Benchmark](doc/benchmark.md)
130133

131134
### FAQ

doc/collective_mode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ python -m paddle.distributed.launch --ips="xx.xx.xx.xx,yy.yy.yy.yy" --gpus 0,1,2
5656

5757
## 修改reader
5858
目前我们paddlerec模型默认使用的reader都是继承自paddle.io.IterableDataset,在reader的__iter__函数中拆分文件,按行处理数据。当 paddle.io.DataLoader 中 num_workers > 0 时,每个子进程都会遍历全量的数据集返回全量样本,所以数据集会重复 num_workers 次,也就是每张卡都会获得全部的数据。您在训练时可能需要调整学习率等参数以保证训练效果。
59-
如果需要数据集样本不会重复,可通过 [paddle.io.get_worker_info](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/fluid/dataloader/dataloader_iter/get_worker_info_cn.html#get-worker-info) 获取各子进程的信息。并在 __iter__ 函数中划分各子进程的数据[paddle.io.IterableDataset](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/fluid/dataloader/dataset/IterableDataset_cn.html#iterabledataset)的相关信息以及划分数据的示例可以点击这里获取。
59+
如果需要数据集样本不会重复,可通过paddle.distributed.get_rank()函数获取当前使用的第几张卡,paddle.distributed.get_world_size()函数获取使用的总卡数。并在reader文件中自行添加逻辑划分各子进程的数据[paddle.io.IterableDataset](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/fluid/dataloader/dataset/IterableDataset_cn.html#iterabledataset)的相关信息以及划分数据的示例可以点击这里获取。

doc/visualization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ visualdl --logdir <dir_1, dir_2, ... , dir_n> --model <model_file> --host <host>
2323
| 参数 | 意义 |
2424
| --------------- | ------------------------------------------------------------ |
2525
| --logdir | 设定日志所在目录,可以指定多个目录,VisualDL将遍历并且迭代寻找指定目录的子目录,将所有实验结果进行可视化 |
26-
| --model | 设定模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](./docs/components/README.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-2) |
26+
| --model | 设定模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](https://github.com/PaddlePaddle/VisualDL/blob/develop/docs/components/README_CN.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-4) |
2727
| --host | 设定IP,默认为`127.0.0.1`,若想使得本机以外的机器访问启动的VisualDL面板,需指定此项为`0.0.0.0`或自己的公网IP地址 |
2828
| --port | 设定端口,默认为`8040` |
2929
| --cache-timeout | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 |
@@ -52,7 +52,7 @@ visualdl.server.app.run(logdir,
5252
| 参数 | 格式 | 含义 |
5353
| ------------- | ------------------------------------------------ | ------------------------------------------------------------ |
5454
| logdir | string或list[string_1, string_2, ... , string_n] | 日志文件所在的路径,VisualDL将在此路径下递归搜索日志文件并进行可视化,可指定单个或多个路径,每个路径中及其子目录中的日志都将视为独立日志展现在前端面板上 |
55-
| model | string | 模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](./docs/components/README.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-2) |
55+
| model | string | 模型文件路径(非文件夹路径),VisualDL将在此路径指定的模型文件进行可视化,目前可支持PaddlePaddle、ONNX、Keras、Core ML、Caffe等多种模型结构,详情可查看[graph支持模型种类](https://github.com/PaddlePaddle/VisualDL/blob/develop/docs/components/README_CN.md#%E5%8A%9F%E8%83%BD%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E-4) |
5656
| host | string | 设定IP,默认为`127.0.0.1`,若想使得本机以外的机器访问启动的VisualDL面板,需指定此项为`0.0.0.0`或自己的公网IP地址 |
5757
| port | int | 启动服务端口,默认为`8040` |
5858
| cache_timeout | int | 后端缓存时间,在缓存时间内前端多次请求同一url,返回的数据从缓存中获取,默认为20秒 |

models/rank/wide_deep/criteo_reader.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,32 @@
1414

1515
from __future__ import print_function
1616
import numpy as np
17-
17+
import paddle
1818
from paddle.io import IterableDataset
1919

2020

2121
class RecDataset(IterableDataset):
2222
def __init__(self, file_list, config):
2323
super(RecDataset, self).__init__()
2424
self.file_list = file_list
25+
if config:
26+
use_fleet = config.get("runner.use_fleet", False)
27+
else:
28+
use_fleet = False
29+
if use_fleet:
30+
worker_id = paddle.distributed.get_rank()
31+
worker_num = paddle.distributed.get_world_size()
32+
file_num = len(file_list)
33+
if file_num < worker_num:
34+
raise ValueError(
35+
"The number of data files is less than the number of workers"
36+
)
37+
blocksize = int(file_num / worker_num)
38+
self.file_list = file_list[worker_id * blocksize:(worker_id + 1) *
39+
blocksize]
40+
remainder = file_num - (blocksize * worker_num)
41+
if worker_id < remainder:
42+
self.file_list.append(file_list[-(worker_id + 1)])
2543
self.init()
2644

2745
def init(self):

models/recall/mind/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ PaddlePaddle>=2.0
7070

7171
python 2.7/3.5/3.6/3.7
7272

73-
os : windows/linux/macos
73+
os : linux/macos
7474

7575
## 快速开始
7676

recserving/movie_recommender/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ score_pairs {
270270
python3 -u ../../../tools/static_trainer.py -m recall/movie.yaml
271271
python3 -u ../../../tools/static_trainer.py -m recall/user.yaml
272272
```
273-
训练好的user/movie模型首先需要参照[Paddle保存的预测模型转为Paddle Serving格式可部署的模型](https://github.com/PaddlePaddle/Serving/blob/develop/doc/INFERENCE_TO_SERVING_CN.md)
273+
训练好的user/movie模型首先需要参照[Paddle保存的预测模型转为Paddle Serving格式可部署的模型](https://github.com/PaddlePaddle/Serving/blob/develop/doc/SAVE_CN.md)
274274

275275
2. 获得用于milvus建库的电影向量文件
276276
`movie.yaml`训练所保存的模型可以用于生成全库的电影向量。需要将数据 movie.dat 复制一份到 get_movie_vector.py 同一目录下,在运行的时候需要直接读取数据集。此外 serving_service 也需要和 get_movie_vector.py 放在同一级目录。运行

0 commit comments

Comments
 (0)