From 7f0c82309356490de73b7a467d0b4ea36fc90db2 Mon Sep 17 00:00:00 2001 From: chengxingyi Date: Fri, 13 Oct 2017 00:58:17 +0800 Subject: [PATCH] lambda cost bug's fix --- paddle/gserver/layers/CostLayer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/gserver/layers/CostLayer.cpp b/paddle/gserver/layers/CostLayer.cpp index ce071323ff5..0bb6f84c22e 100644 --- a/paddle/gserver/layers/CostLayer.cpp +++ b/paddle/gserver/layers/CostLayer.cpp @@ -462,8 +462,8 @@ void LambdaCost::calcGrad(const real* outputScore, real score_j = score[index_j]; real dcgDif = 0; if (j < sortSize) { - dcgDif = (std::pow(2, score_i) - std::pow(2, score_j)) / - (std::log(i + 2) - std::log(j + 2)); + dcgDif = (std::pow(2, score_i) - std::pow(2, score_j)) * + (1 / std::log(i + 2) - 1 / std::log(j + 2)); } else { dcgDif = (std::pow(2, score_i) - std::pow(2, score_j)) / std::log(i + 2); -- GitLab