From d7777a77e600dc41044b9a4e7429bf7d7afdba02 Mon Sep 17 00:00:00 2001 From: xjqbest <173596896@qq.com> Date: Thu, 28 May 2020 13:41:24 +0800 Subject: [PATCH] fix --- models/rank/dnn/config.yaml | 5 +++++ models/rank/dnn/model.py | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/models/rank/dnn/config.yaml b/models/rank/dnn/config.yaml index 9db1f9bb..29080797 100755 --- a/models/rank/dnn/config.yaml +++ b/models/rank/dnn/config.yaml @@ -61,3 +61,8 @@ executor: dataset_name: dataset_2 # 名字,用来区分不同的阶段 thread_num: 1 # 线程数 is_infer: False # 是否是infer +# - name: infer +# model: "{workspace}/model.py" # 模型路径 +# dataset_name: dataset_2 # 名字,用来区分不同的阶段 +# thread_num: 1 # 线程数 +# is_infer: True # 是否是infer diff --git a/models/rank/dnn/model.py b/models/rank/dnn/model.py index 0f268164..d417d4d9 100755 --- a/models/rank/dnn/model.py +++ b/models/rank/dnn/model.py @@ -77,17 +77,21 @@ class Model(ModelBase): self.predict = predict - cost = fluid.layers.cross_entropy( - input=self.predict, label=self.label_input) - avg_cost = fluid.layers.reduce_mean(cost) - self._cost = avg_cost - auc, batch_auc, _ = fluid.layers.auc(input=self.predict, label=self.label_input, num_thresholds=2**12, slide_steps=20) + if is_infer: + self._infer_results["AUC"] = auc + self._infer_results["BATCH_AUC"] = batch_auc + return + self._metrics["AUC"] = auc self._metrics["BATCH_AUC"] = batch_auc + cost = fluid.layers.cross_entropy( + input=self.predict, label=self.label_input) + avg_cost = fluid.layers.reduce_mean(cost) + self._cost = avg_cost def optimizer(self): optimizer = fluid.optimizer.Adam(self.learning_rate, lazy_mode=True) -- GitLab