From cd2f8f9e511ecf82647b0bc952e0ff0e5e1fa864 Mon Sep 17 00:00:00 2001 From: Chengmo Date: Wed, 17 Jun 2020 15:20:40 +0800 Subject: [PATCH] Fix infer (#98) * fix esmm * single infer -> infer * fix increment folder repeated Co-authored-by: tangwei --- models/contentunderstanding/readme.md | 4 +- models/demo/movie_recommand/rank/config.yaml | 3 +- .../demo/movie_recommand/recall/config.yaml | 3 +- models/match/dssm/config.yaml | 4 +- models/match/multiview-simnet/config.yaml | 4 +- models/match/readme.md | 2 +- models/multitask/esmm/config.yaml | 71 +++++++++---------- models/multitask/mmoe/config.yaml | 3 +- models/multitask/readme.md | 2 +- models/multitask/share-bottom/config.yaml | 3 +- models/rank/afm/config.yaml | 3 +- models/rank/dcn/config.yaml | 2 +- models/rank/deep_crossing/config.yaml | 3 +- models/rank/deepfm/config.yaml | 3 +- models/rank/din/config.yaml | 3 +- models/rank/ffm/config.yaml | 3 +- models/rank/fgcnn/config.yaml | 3 +- models/rank/fm/config.yaml | 3 +- models/rank/fnn/config.yaml | 3 +- models/rank/logistic_regression/config.yaml | 3 +- models/rank/nfm/config.yaml | 3 +- models/rank/pnn/config.yaml | 3 +- models/rank/readme.md | 2 +- models/rank/wide_deep/config.yaml | 3 +- models/rank/xdeepfm/config.yaml | 3 +- models/recall/gnn/config.yaml | 4 +- models/recall/gru4rec/config.yaml | 3 +- models/recall/ncf/config.yaml | 3 +- models/recall/readme.md | 2 +- models/recall/ssr/config.yaml | 3 +- models/recall/word2vec/config.yaml | 4 +- models/rerank/listwise/config.yaml | 3 +- models/treebased/tdm/config.yaml | 4 +- tools/build_script.sh | 2 +- 34 files changed, 69 insertions(+), 101 deletions(-) diff --git a/models/contentunderstanding/readme.md b/models/contentunderstanding/readme.md index 56ec74a3..59bddb16 100644 --- a/models/contentunderstanding/readme.md +++ b/models/contentunderstanding/readme.md @@ -86,7 +86,7 @@ python -m paddlerec.run -m ./config.yaml # 自定义修改超参后,指定配 # 修改对应模型的config.yaml, workspace配置为当前目录的绝对路径 # 修改对应模型的config.yaml,mode配置infer_runner # 示例: mode: train_runner -> mode: infer_runner -# infer_runner中 class配置为 class: single_infer +# infer_runner中 class配置为 class: infer # 修改phase阶段为infer的配置,参照config注释 # 修改完config.yaml后 执行: @@ -106,7 +106,7 @@ python -m paddlerec.run -m ./config.yaml # 自定义修改超参后,指定配 # 修改对应模型的config.yaml, workspace配置为当前目录的绝对路径 # 修改对应模型的config.yaml,mode配置infer_runner # 示例: mode: train_runner -> mode: infer_runner -# infer_runner中 class配置为 class: single_infer +# infer_runner中 class配置为 class: infer # 修改phase阶段为infer的配置,参照config注释 # 修改完config.yaml后 执行: diff --git a/models/demo/movie_recommand/rank/config.yaml b/models/demo/movie_recommand/rank/config.yaml index 8f11d51f..94e7b0f1 100644 --- a/models/demo/movie_recommand/rank/config.yaml +++ b/models/demo/movie_recommand/rank/config.yaml @@ -64,8 +64,7 @@ runner: device: cpu - name: runner_infer - epochs: 1 - class: single_infer + class: infer print_interval: 10000 init_model_path: "increment/9" # load model path diff --git a/models/demo/movie_recommand/recall/config.yaml b/models/demo/movie_recommand/recall/config.yaml index ca24df12..4b683c1c 100644 --- a/models/demo/movie_recommand/recall/config.yaml +++ b/models/demo/movie_recommand/recall/config.yaml @@ -64,8 +64,7 @@ runner: device: cpu - name: runner_infer - epochs: 1 - class: single_infer + class: infer print_interval: 10000 init_model_path: "increment/9" # load model path diff --git a/models/match/dssm/config.yaml b/models/match/dssm/config.yaml index 7d28f3de..8f97c496 100755 --- a/models/match/dssm/config.yaml +++ b/models/match/dssm/config.yaml @@ -56,9 +56,7 @@ runner: init_model_path: "" # load model path print_interval: 2 - name: infer_runner - class: single_infer - # num of epochs - epochs: 1 + class: infer # device to run training or infer device: cpu print_interval: 1 diff --git a/models/match/multiview-simnet/config.yaml b/models/match/multiview-simnet/config.yaml index 3cf6c97f..bff01ae6 100755 --- a/models/match/multiview-simnet/config.yaml +++ b/models/match/multiview-simnet/config.yaml @@ -63,9 +63,7 @@ runner: init_model_path: "" # load model path print_interval: 1 - name: infer_runner - class: single_infer - # num of epochs - epochs: 1 + class: infer # device to run training or infer device: cpu print_interval: 1 diff --git a/models/match/readme.md b/models/match/readme.md index f8f00088..38e72229 100755 --- a/models/match/readme.md +++ b/models/match/readme.md @@ -43,7 +43,7 @@ python -m paddlerec.run -m paddlerec.models.match.multiview-simnet # multiview-s # 修改对应模型的config.yaml, workspace配置为当前目录的绝对路径 # 修改对应模型的config.yaml,mode配置infer_runner # 示例: mode: train_runner -> mode: infer_runner -# infer_runner中 class配置为 class: single_infer +# infer_runner中 class配置为 class: infer # 修改phase阶段为infer的配置,参照config注释 # 修改完config.yaml后 执行: diff --git a/models/multitask/esmm/config.yaml b/models/multitask/esmm/config.yaml index 9606ca79..d160f164 100644 --- a/models/multitask/esmm/config.yaml +++ b/models/multitask/esmm/config.yaml @@ -16,21 +16,21 @@ workspace: "paddlerec.models.multitask.esmm" dataset: -- name: dataset_train - batch_size: 1 - type: QueueDataset - data_path: "{workspace}/data/train" - data_converter: "{workspace}/esmm_reader.py" -- name: dataset_infer - batch_size: 1 - type: QueueDataset - data_path: "{workspace}/data/test" - data_converter: "{workspace}/esmm_reader.py" + - name: dataset_train + batch_size: 1 + type: QueueDataset + data_path: "{workspace}/data/train" + data_converter: "{workspace}/esmm_reader.py" + - name: dataset_infer + batch_size: 1 + type: QueueDataset + data_path: "{workspace}/data/test" + data_converter: "{workspace}/esmm_reader.py" hyper_parameters: vocab_size: 10000 embed_size: 128 - optimizer: + optimizer: class: adam learning_rate: 0.001 strategy: async @@ -39,30 +39,29 @@ hyper_parameters: mode: [train_runner, infer_runner] runner: -- name: train_runner - class: train - device: cpu - epochs: 3 - save_checkpoint_interval: 2 - save_inference_interval: 4 - save_checkpoint_path: "increment" - save_inference_path: "inference" - print_interval: 10 - phases: [train] -- name: infer_runner - class: infer - init_model_path: "increment/0" - device: cpu - epochs: 1 - print_interval: 1 - phases: [infer] + - name: train_runner + class: train + device: cpu + epochs: 3 + save_checkpoint_interval: 2 + save_inference_interval: 4 + save_checkpoint_path: "increment" + save_inference_path: "inference" + print_interval: 10 + phases: [train] + - name: infer_runner + class: infer + init_model_path: "increment/1" + device: cpu + print_interval: 1 + phases: [infer] phase: -- name: train - model: "{workspace}/model.py" - dataset_name: dataset_train - thread_num: 1 -- name: infer - model: "{workspace}/model.py" - dataset_name: dataset_infer - thread_num: 1 + - name: train + model: "{workspace}/model.py" + dataset_name: dataset_train + thread_num: 1 + - name: infer + model: "{workspace}/model.py" + dataset_name: dataset_infer + thread_num: 1 diff --git a/models/multitask/mmoe/config.yaml b/models/multitask/mmoe/config.yaml index 751ed198..63f052be 100644 --- a/models/multitask/mmoe/config.yaml +++ b/models/multitask/mmoe/config.yaml @@ -52,10 +52,9 @@ runner: save_inference_path: "inference" print_interval: 10 - name: infer_runner - class: single_infer + class: infer init_model_path: "increment/0" device: cpu - epochs: 3 phase: - name: train diff --git a/models/multitask/readme.md b/models/multitask/readme.md index 4a377da6..7bf23ae3 100755 --- a/models/multitask/readme.md +++ b/models/multitask/readme.md @@ -77,7 +77,7 @@ python -m paddlerec.run -m ./config.yaml # 自定义修改超参后,指定配 # 修改对应模型的config.yaml, workspace配置为当前目录的绝对路径 # 修改对应模型的config.yaml,mode配置infer_runner # 示例: mode: train_runner -> mode: infer_runner -# infer_runner中 class配置为 class: single_infer +# infer_runner中 class配置为 class: infer # 修改phase阶段为infer的配置,参照config注释 # 修改完config.yaml后 执行: diff --git a/models/multitask/share-bottom/config.yaml b/models/multitask/share-bottom/config.yaml index ebbdfcc2..9abb67db 100644 --- a/models/multitask/share-bottom/config.yaml +++ b/models/multitask/share-bottom/config.yaml @@ -51,10 +51,9 @@ runner: save_inference_path: "inference" print_interval: 5 - name: infer_runner - class: single_infer + class: infer init_model_path: "increment/0" device: cpu - epochs: 3 phase: - name: train diff --git a/models/rank/afm/config.yaml b/models/rank/afm/config.yaml index 81cc01a6..c55a9694 100644 --- a/models/rank/afm/config.yaml +++ b/models/rank/afm/config.yaml @@ -59,8 +59,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/dcn/config.yaml b/models/rank/dcn/config.yaml index e7538744..2f8a1be4 100755 --- a/models/rank/dcn/config.yaml +++ b/models/rank/dcn/config.yaml @@ -60,7 +60,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer + class: infer epochs: 1 device: cpu init_model_path: "increment/0" diff --git a/models/rank/deep_crossing/config.yaml b/models/rank/deep_crossing/config.yaml index 5033cd56..54a4a895 100755 --- a/models/rank/deep_crossing/config.yaml +++ b/models/rank/deep_crossing/config.yaml @@ -58,8 +58,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/deepfm/config.yaml b/models/rank/deepfm/config.yaml index 8443d45a..10c6fa35 100755 --- a/models/rank/deepfm/config.yaml +++ b/models/rank/deepfm/config.yaml @@ -58,8 +58,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/din/config.yaml b/models/rank/din/config.yaml index ab327885..95693c6d 100755 --- a/models/rank/din/config.yaml +++ b/models/rank/din/config.yaml @@ -56,8 +56,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/ffm/config.yaml b/models/rank/ffm/config.yaml index 863ff6c0..26240706 100644 --- a/models/rank/ffm/config.yaml +++ b/models/rank/ffm/config.yaml @@ -57,8 +57,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/fgcnn/config.yaml b/models/rank/fgcnn/config.yaml index 24ee2636..c329c7ea 100755 --- a/models/rank/fgcnn/config.yaml +++ b/models/rank/fgcnn/config.yaml @@ -62,8 +62,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/fm/config.yaml b/models/rank/fm/config.yaml index 617d727c..e9f30573 100644 --- a/models/rank/fm/config.yaml +++ b/models/rank/fm/config.yaml @@ -57,8 +57,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/fnn/config.yaml b/models/rank/fnn/config.yaml index 16e985e2..6f3995d8 100755 --- a/models/rank/fnn/config.yaml +++ b/models/rank/fnn/config.yaml @@ -68,8 +68,7 @@ runner: save_inference_path: "inference_fnn" print_interval: 1 - name: infer_runner - trainer_class: single_infer - epochs: 1 + trainer_class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/logistic_regression/config.yaml b/models/rank/logistic_regression/config.yaml index 4dbb48ca..8e88ee1b 100644 --- a/models/rank/logistic_regression/config.yaml +++ b/models/rank/logistic_regression/config.yaml @@ -56,8 +56,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/nfm/config.yaml b/models/rank/nfm/config.yaml index ffea3462..266cdfbe 100644 --- a/models/rank/nfm/config.yaml +++ b/models/rank/nfm/config.yaml @@ -63,8 +63,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/pnn/config.yaml b/models/rank/pnn/config.yaml index 836e3175..4624d938 100644 --- a/models/rank/pnn/config.yaml +++ b/models/rank/pnn/config.yaml @@ -60,8 +60,7 @@ runner: save_inference_path: "inference" print_interval: 1 - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" print_interval: 1 diff --git a/models/rank/readme.md b/models/rank/readme.md index d94f359f..51438fd6 100755 --- a/models/rank/readme.md +++ b/models/rank/readme.md @@ -98,7 +98,7 @@ python -m paddlerec.run -m ./config.yaml ``` # 修改对应模型的config.yaml,mode配置infer_runner # 示例: mode: runner1 -> mode: infer_runner -# infer_runner中 class配置为 class: single_infer +# infer_runner中 class配置为 class: infer # 如果训练阶段和预测阶段的模型输入一致,phase不需要改动,复用train的即可 # 修改完config.yaml后 执行: diff --git a/models/rank/wide_deep/config.yaml b/models/rank/wide_deep/config.yaml index 16c11205..1ff5232e 100755 --- a/models/rank/wide_deep/config.yaml +++ b/models/rank/wide_deep/config.yaml @@ -54,8 +54,7 @@ runner: save_checkpoint_path: "increment" save_inference_path: "inference" - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" diff --git a/models/rank/xdeepfm/config.yaml b/models/rank/xdeepfm/config.yaml index 0571a88b..716513d4 100755 --- a/models/rank/xdeepfm/config.yaml +++ b/models/rank/xdeepfm/config.yaml @@ -55,8 +55,7 @@ runner: save_checkpoint_path: "increment" save_inference_path: "inference" - name: infer_runner - class: single_infer - epochs: 1 + class: infer device: cpu init_model_path: "increment/0" diff --git a/models/recall/gnn/config.yaml b/models/recall/gnn/config.yaml index 88ff55f5..ed290b2f 100755 --- a/models/recall/gnn/config.yaml +++ b/models/recall/gnn/config.yaml @@ -61,9 +61,7 @@ runner: init_model_path: "" # load model path print_interval: 1 - name: infer_runner - class: single_infer - # num of epochs - epochs: 1 + class: infer # device to run training or infer device: cpu print_interval: 1 diff --git a/models/recall/gru4rec/config.yaml b/models/recall/gru4rec/config.yaml index b74db3dd..98250ae0 100644 --- a/models/recall/gru4rec/config.yaml +++ b/models/recall/gru4rec/config.yaml @@ -54,10 +54,9 @@ runner: save_inference_path: "inference" print_interval: 10 - name: infer_runner - class: single_infer + class: infer init_model_path: "increment/0" device: cpu - epochs: 1 phase: - name: train diff --git a/models/recall/ncf/config.yaml b/models/recall/ncf/config.yaml index 2d603397..3c87eb3b 100644 --- a/models/recall/ncf/config.yaml +++ b/models/recall/ncf/config.yaml @@ -51,10 +51,9 @@ runner: save_inference_path: "inference" print_interval: 10 - name: infer_runner - class: single_infer + class: infer init_model_path: "increment/0" device: cpu - epochs: 1 phase: - name: train diff --git a/models/recall/readme.md b/models/recall/readme.md index bb0539b2..e5589188 100755 --- a/models/recall/readme.md +++ b/models/recall/readme.md @@ -95,7 +95,7 @@ python -m paddlerec.run -m ./config.yaml # 自定义修改超参后,指定配 # 修改对应模型的config.yaml, workspace配置为当前目录的绝对路径 # 修改对应模型的config.yaml,mode配置infer_runner # 示例: mode: train_runner -> mode: infer_runner -# infer_runner中 class配置为 class: single_infer +# infer_runner中 class配置为 class: infer # 修改phase阶段为infer的配置,参照config注释 # 修改完config.yaml后 执行: diff --git a/models/recall/ssr/config.yaml b/models/recall/ssr/config.yaml index ae23609e..5152c20c 100644 --- a/models/recall/ssr/config.yaml +++ b/models/recall/ssr/config.yaml @@ -50,10 +50,9 @@ runner: save_inference_path: "inference" print_interval: 10 - name: infer_runner - class: single_infer + class: infer init_model_path: "increment/0" device: cpu - epochs: 1 phase: - name: train diff --git a/models/recall/word2vec/config.yaml b/models/recall/word2vec/config.yaml index 36261986..34a25e59 100755 --- a/models/recall/word2vec/config.yaml +++ b/models/recall/word2vec/config.yaml @@ -61,9 +61,7 @@ runner: init_model_path: "" # load model path print_interval: 1 - name: infer_runner - class: single_infer - # num of epochs - epochs: 1 + class: infer # device to run training or infer device: cpu init_model_path: "increment/0" # load model path diff --git a/models/rerank/listwise/config.yaml b/models/rerank/listwise/config.yaml index 8891a057..6d06ab09 100644 --- a/models/rerank/listwise/config.yaml +++ b/models/rerank/listwise/config.yaml @@ -51,10 +51,9 @@ runner: save_checkpoint_path: "increment" save_inference_path: "inference" - name: infer_runner - class: single_infer + class: infer init_model_path: "increment/0" device: cpu - epochs: 3 phase: - name: train diff --git a/models/treebased/tdm/config.yaml b/models/treebased/tdm/config.yaml index 3ed4a257..e5920803 100755 --- a/models/treebased/tdm/config.yaml +++ b/models/treebased/tdm/config.yaml @@ -80,10 +80,8 @@ runner: print_interval: 10 - name: runner2 - class: single_infer + class: infer startup_class_path: "{workspace}/tdm_startup.py" - # num of epochs - epochs: 1 # device to run training or infer device: cpu init_model_path: "increment/0" # load model path diff --git a/tools/build_script.sh b/tools/build_script.sh index 9e5e27e3..b39b97f8 100755 --- a/tools/build_script.sh +++ b/tools/build_script.sh @@ -49,7 +49,7 @@ function model_test() { root_dir=`pwd` all_model=$(find ${root_dir} -name config.yaml) - special_models=("demo" "pnn" "fgcnn" "esmm") + special_models=("demo" "pnn" "fgcnn" "gru4rec" "tagspace") for model in ${all_model} do -- GitLab