From 0e34948a38ac214a9b80aa13d291ef386d73b4f5 Mon Sep 17 00:00:00 2001 From: barrierye Date: Mon, 20 Apr 2020 17:44:34 +0800 Subject: [PATCH] fix bug --- core/general-client/include/general_model.h | 10 ++++++++++ doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING.md | 4 ++-- doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING_CN.md | 4 ++-- python/examples/imdb/test_ensemble_client.py | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/general-client/include/general_model.h b/core/general-client/include/general_model.h index 9059a266..9d0cc8b6 100644 --- a/core/general-client/include/general_model.h +++ b/core/general-client/include/general_model.h @@ -49,6 +49,8 @@ class ModelRes { res._int64_value_map.end()); _float_value_map.insert(res._float_value_map.begin(), res._float_value_map.end()); + _shape_map.insert(res._shape_map.begin(), res._shape_map.end()); + _lod_map.insert(res._lod_map.begin(), res._lod_map.end()); } ModelRes(ModelRes&& res) { _engine_name = std::move(res._engine_name); @@ -58,6 +60,10 @@ class ModelRes { _float_value_map.insert( std::make_move_iterator(std::begin(res._float_value_map)), std::make_move_iterator(std::end(res._float_value_map))); + _shape_map.insert(std::make_move_iterator(std::begin(res._shape_map)), + std::make_move_iterator(std::end(res._shape_map))); + _lod_map.insert(std::make_move_iterator(std::begin(res._lod_map)), + std::make_move_iterator(std::end(res._lod_map))); } ~ModelRes() {} const std::vector& get_int64_by_name(const std::string& name) { @@ -85,6 +91,10 @@ class ModelRes { _float_value_map.insert( std::make_move_iterator(std::begin(res._float_value_map)), std::make_move_iterator(std::end(res._float_value_map))); + _shape_map.insert(std::make_move_iterator(std::begin(res._shape_map)), + std::make_move_iterator(std::end(res._shape_map))); + _lod_map.insert(std::make_move_iterator(std::begin(res._lod_map)), + std::make_move_iterator(std::end(res._lod_map))); } return *this; } diff --git a/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING.md b/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING.md index dd83bc29..7f583342 100644 --- a/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING.md +++ b/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING.md @@ -100,11 +100,11 @@ for i in range(3): fetch = ["acc", "cost", "prediction"] fetch_maps = client.predict(feed=feed, fetch=fetch) if len(fetch_maps) == 1: - print("step: {}, res: {}".format(i, fetch_maps['prediction'][1])) + print("step: {}, res: {}".format(i, fetch_maps['prediction'][0][1])) else: for model, fetch_map in fetch_maps.items(): print("step: {}, model: {}, res: {}".format(i, model, fetch_map[ - 'prediction'][1])) + 'prediction'][0][1])) ``` Compared with the normal prediction service, the client side has not changed much. When multiple model predictions are used, the prediction service will return a dictionary with engine name `engine_name`(the value is defined on the server side) as the key, and the corresponding model prediction results as the value. diff --git a/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING_CN.md b/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING_CN.md index 12af427e..ee816aa5 100644 --- a/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING_CN.md +++ b/doc/MODEL_ENSEMBLE_IN_PADDLE_SERVING_CN.md @@ -100,11 +100,11 @@ for i in range(3): fetch = ["acc", "cost", "prediction"] fetch_maps = client.predict(feed=feed, fetch=fetch) if len(fetch_maps) == 1: - print("step: {}, res: {}".format(i, fetch_maps['prediction'][1])) + print("step: {}, res: {}".format(i, fetch_maps['prediction'][0][1])) else: for model, fetch_map in fetch_maps.items(): print("step: {}, model: {}, res: {}".format(i, model, fetch_map[ - 'prediction'][1])) + 'prediction'][0][1])) ``` Client端与普通预测服务没有发生太大的变化。当使用多个模型预测时,预测服务将返回一个key为Server端定义的引擎名称`engine_name`,value为对应的模型预测结果的字典。 diff --git a/python/examples/imdb/test_ensemble_client.py b/python/examples/imdb/test_ensemble_client.py index 5fd97f66..6cafb338 100644 --- a/python/examples/imdb/test_ensemble_client.py +++ b/python/examples/imdb/test_ensemble_client.py @@ -35,8 +35,8 @@ for i in range(3): fetch = ["acc", "cost", "prediction"] fetch_maps = client.predict(feed=feed, fetch=fetch) if len(fetch_maps) == 1: - print("step: {}, res: {}".format(i, fetch_maps['prediction'][1])) + print("step: {}, res: {}".format(i, fetch_maps['prediction'][0][1])) else: for model, fetch_map in fetch_maps.items(): print("step: {}, model: {}, res: {}".format(i, model, fetch_map[ - 'prediction'][1])) + 'prediction'][0][1])) -- GitLab