mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 13:17:44 +00:00
Removed LOSS_FUNCTION_IS_CROSS_ENTOROPY macro.
This commit is contained in:
+1
-8
@@ -9,11 +9,6 @@
|
|||||||
// Select the objective function
|
// 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
|
// 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
|
// #define LOSS_FUNCTION_IS_CROSS_ENTOROPY_FOR_VALUE
|
||||||
|
|
||||||
@@ -121,9 +116,7 @@ typedef float LearnFloatType;
|
|||||||
|
|
||||||
#define LOSS_FUNCTION_IS_ELMO_METHOD
|
#define LOSS_FUNCTION_IS_ELMO_METHOD
|
||||||
|
|
||||||
#if defined(LOSS_FUNCTION_IS_CROSS_ENTOROPY)
|
#if defined(LOSS_FUNCTION_IS_CROSS_ENTOROPY_FOR_VALUE)
|
||||||
#define LOSS_FUNCTION "CROSS_ENTOROPY"
|
|
||||||
#elif defined(LOSS_FUNCTION_IS_CROSS_ENTOROPY_FOR_VALUE)
|
|
||||||
#define LOSS_FUNCTION "CROSS_ENTOROPY_FOR_VALUE"
|
#define LOSS_FUNCTION "CROSS_ENTOROPY_FOR_VALUE"
|
||||||
#elif defined(LOSS_FUNCTION_IS_ELMO_METHOD)
|
#elif defined(LOSS_FUNCTION_IS_ELMO_METHOD)
|
||||||
#define LOSS_FUNCTION "ELMO_METHOD(WCSC27)"
|
#define LOSS_FUNCTION "ELMO_METHOD(WCSC27)"
|
||||||
|
|||||||
@@ -163,35 +163,6 @@ namespace Learner
|
|||||||
return ((y2 - y1) / epsilon) / winning_probability_coefficient;
|
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 )
|
#if defined ( LOSS_FUNCTION_IS_CROSS_ENTOROPY_FOR_VALUE )
|
||||||
double calc_grad(Value deep, Value shallow, const PackedSfenValue& psv)
|
double calc_grad(Value deep, Value shallow, const PackedSfenValue& psv)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user