From f52fbf8006174023fa137feda1d7db67a884ac2e Mon Sep 17 00:00:00 2001 From: nodchip Date: Wed, 9 Sep 2020 00:10:04 +0900 Subject: [PATCH] Removed LOSS_FUNCTION_IS_CROSS_ENTOROPY macro. --- src/learn/learn.h | 9 +-------- src/learn/learner.cpp | 29 ----------------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/src/learn/learn.h b/src/learn/learn.h index 9d783986..da542d67 100644 --- a/src/learn/learn.h +++ b/src/learn/learn.h @@ -9,11 +9,6 @@ // Select the objective function // ---------------------- -// Objective function is cross entropy -// See learner.cpp for more information. -// So-called ordinary "rag cloth squeezer" -//#define LOSS_FUNCTION_IS_CROSS_ENTOROPY - // A version in which the objective function is cross entropy, but the win rate function is not passed // #define LOSS_FUNCTION_IS_CROSS_ENTOROPY_FOR_VALUE @@ -121,9 +116,7 @@ typedef float LearnFloatType; #define LOSS_FUNCTION_IS_ELMO_METHOD -#if defined(LOSS_FUNCTION_IS_CROSS_ENTOROPY) -#define LOSS_FUNCTION "CROSS_ENTOROPY" -#elif defined(LOSS_FUNCTION_IS_CROSS_ENTOROPY_FOR_VALUE) +#if defined(LOSS_FUNCTION_IS_CROSS_ENTOROPY_FOR_VALUE) #define LOSS_FUNCTION "CROSS_ENTOROPY_FOR_VALUE" #elif defined(LOSS_FUNCTION_IS_ELMO_METHOD) #define LOSS_FUNCTION "ELMO_METHOD(WCSC27)" diff --git a/src/learn/learner.cpp b/src/learn/learner.cpp index e9658da6..66835ce5 100644 --- a/src/learn/learner.cpp +++ b/src/learn/learner.cpp @@ -163,35 +163,6 @@ namespace Learner return ((y2 - y1) / epsilon) / winning_probability_coefficient; } -#if defined (LOSS_FUNCTION_IS_CROSS_ENTOROPY) - double calc_grad(Value deep, Value shallow, const PackedSfenValue& psv) - { - // Objective function with cross entropy - - // For the concept and nature of cross entropy, - // http://nnadl-ja.github.io/nnadl_site_ja/chap3.html#the_cross-entropy_cost_function - // http://postd.cc/visual-information-theory-3/ - // Refer to etc. - - // Objective function design) - // We want to make the distribution of p closer to the distribution of q - // → Think of it as the problem of minimizing the cross entropy - // between the probability distributions of p and q. - // J = H(p,q) =-Σ p(x) log(q(x)) = -p log q-(1-p) log(1-q) - // x - - // p is a constant and q is a Wi function (q = σ(W・Xi) ). - // ∂J/∂Wi = -p・q'/q-(1-p)(1-q)'/(1-q) - // = ... - // = q-p. - - const double p = winning_percentage(deep, psv.gamePly); - const double q = winning_percentage(shallow, psv.gamePly); - - return q - p; - } -#endif - #if defined ( LOSS_FUNCTION_IS_CROSS_ENTOROPY_FOR_VALUE ) double calc_grad(Value deep, Value shallow, const PackedSfenValue& psv) {