mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-25 03:26:24 +08:00
Removed EVAL_NNUE macro.
This commit is contained in:
@@ -903,7 +903,7 @@ icc-profile-use:
|
||||
|
||||
learn: config-sanity
|
||||
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
|
||||
EXTRACXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \
|
||||
EXTRACXXFLAGS=' -DEVAL_LEARN -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \
|
||||
EXTRALDFLAGS=' $(BLASLDFLAGS) -fopenmp ' \
|
||||
all
|
||||
|
||||
@@ -911,7 +911,7 @@ profile-learn: net config-sanity objclean profileclean
|
||||
@echo ""
|
||||
@echo "Step 1/4. Building instrumented executable ..."
|
||||
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) \
|
||||
LEARNCXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \
|
||||
LEARNCXXFLAGS=' -DEVAL_LEARN -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \
|
||||
LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp '
|
||||
@echo ""
|
||||
@echo "Step 2/4. Running benchmark for pgo-build ..."
|
||||
@@ -920,7 +920,7 @@ profile-learn: net config-sanity objclean profileclean
|
||||
@echo "Step 3/4. Building optimized executable ..."
|
||||
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
|
||||
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) \
|
||||
LEARNCXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \
|
||||
LEARNCXXFLAGS=' -DEVAL_LEARN -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \
|
||||
LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp '
|
||||
@echo ""
|
||||
@echo "Step 4/4. Deleting profile data ..."
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
// A common header-like function for modern evaluation functions (EVAL_KPPT and EVAL_KPP_KKPT).
|
||||
|
||||
#if defined(EVAL_NNUE) || defined(EVAL_LEARN)
|
||||
#include <functional>
|
||||
|
||||
// KK file name
|
||||
@@ -79,6 +78,4 @@ namespace Eval
|
||||
|
||||
}
|
||||
|
||||
#endif // defined(EVAL_NNUE) || defined(EVAL_LEARN)
|
||||
|
||||
#endif // _EVALUATE_KPPT_COMMON_H_
|
||||
|
||||
@@ -1,45 +1,41 @@
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include "../eval/evaluate_common.h"
|
||||
|
||||
#include "learn.h"
|
||||
#include "multi_think.h"
|
||||
#include "../misc.h"
|
||||
#include "../thread.h"
|
||||
#include "../nnue/evaluate_nnue_learner.h"
|
||||
#include "../position.h"
|
||||
#include "../syzygy/tbprobe.h"
|
||||
#include "../thread.h"
|
||||
#include "../tt.h"
|
||||
#include "../uci.h"
|
||||
#include "../syzygy/tbprobe.h"
|
||||
#include "learn.h"
|
||||
#include "multi_think.h"
|
||||
|
||||
#if defined(USE_BOOK)
|
||||
#include "../extra/book/book.h"
|
||||
#endif
|
||||
|
||||
#include <chrono>
|
||||
#include <random>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <unordered_set>
|
||||
#include <iomanip>
|
||||
#include <list>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <random>
|
||||
#include <regex>
|
||||
#include <shared_mutex>
|
||||
#include <sstream>
|
||||
#include <unordered_set>
|
||||
|
||||
#if defined (_OPENMP)
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
#include "../nnue/evaluate_nnue_learner.h"
|
||||
#include <climits>
|
||||
#include <shared_mutex>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Learner
|
||||
@@ -692,12 +688,10 @@ namespace Learner
|
||||
// performed unless each node evaluate() is called!
|
||||
// If the depth is 8 or more, it seems
|
||||
// faster not to calculate this difference.
|
||||
#if defined(EVAL_NNUE)
|
||||
if (depth < 8)
|
||||
{
|
||||
Eval::NNUE::update_eval(pos);
|
||||
}
|
||||
#endif // defined(EVAL_NNUE)
|
||||
}
|
||||
|
||||
// Reach leaf
|
||||
|
||||
@@ -17,45 +17,40 @@
|
||||
// → I will not be involved in the engine because it is a problem that the GUI should assist.
|
||||
// etc..
|
||||
|
||||
#define EVAL_LEARN
|
||||
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include "../eval/evaluate_common.h"
|
||||
|
||||
#include "../misc.h"
|
||||
#include "../nnue/evaluate_nnue_learner.h"
|
||||
#include "../position.h"
|
||||
#include "../syzygy/tbprobe.h"
|
||||
#include "../thread.h"
|
||||
#include "../tt.h"
|
||||
#include "../uci.h"
|
||||
#include "learn.h"
|
||||
#include "multi_think.h"
|
||||
#include "../uci.h"
|
||||
#include "../syzygy/tbprobe.h"
|
||||
#include "../misc.h"
|
||||
#include "../thread.h"
|
||||
#include "../position.h"
|
||||
#include "../tt.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <random>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <unordered_set>
|
||||
#include <iomanip>
|
||||
#include <list>
|
||||
#include <climits>
|
||||
#include <cmath> // std::exp(),std::pow(),std::log()
|
||||
#include <cstring> // memcpy()
|
||||
#include <memory>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <random>
|
||||
#include <regex>
|
||||
#include <shared_mutex>
|
||||
#include <sstream>
|
||||
#include <unordered_set>
|
||||
|
||||
#if defined (_OPENMP)
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
#include "../nnue/evaluate_nnue_learner.h"
|
||||
#include <climits>
|
||||
#include <shared_mutex>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -724,14 +719,12 @@ namespace Learner
|
||||
learn_sum_entropy = 0.0;
|
||||
#endif
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
newbob_scale = 1.0;
|
||||
newbob_decay = 1.0;
|
||||
newbob_num_trials = 2;
|
||||
best_loss = std::numeric_limits<double>::infinity();
|
||||
latest_loss_sum = 0.0;
|
||||
latest_loss_count = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void thread_worker(size_t thread_id);
|
||||
@@ -787,7 +780,6 @@ namespace Learner
|
||||
atomic<double> learn_sum_entropy;
|
||||
#endif
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
shared_timed_mutex nn_mutex;
|
||||
double newbob_scale;
|
||||
double newbob_decay;
|
||||
@@ -796,7 +788,6 @@ namespace Learner
|
||||
double latest_loss_sum;
|
||||
uint64_t latest_loss_count;
|
||||
std::string best_nn_directory;
|
||||
#endif
|
||||
|
||||
uint64_t eval_save_interval;
|
||||
uint64_t loss_output_interval;
|
||||
@@ -844,13 +835,10 @@ namespace Learner
|
||||
// It doesn't matter if you have disabled the substitution table.
|
||||
TT.new_search();
|
||||
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
std::cout << "PROGRESS: " << now_string() << ", ";
|
||||
std::cout << sr.total_done << " sfens";
|
||||
std::cout << ", iteration " << epoch;
|
||||
std::cout << ", eta = " << Eval::get_eta() << ", ";
|
||||
#endif
|
||||
|
||||
#if !defined(LOSS_FUNCTION_IS_ELMO_METHOD)
|
||||
double sum_error = 0;
|
||||
@@ -1009,10 +997,8 @@ namespace Learner
|
||||
#endif
|
||||
|
||||
#if defined(LOSS_FUNCTION_IS_ELMO_METHOD)
|
||||
#if defined(EVAL_NNUE)
|
||||
latest_loss_sum += test_sum_cross_entropy - test_sum_entropy;
|
||||
latest_loss_count += sr.sfen_for_mse.size();
|
||||
#endif
|
||||
|
||||
// learn_cross_entropy may be called train cross
|
||||
// entropy in the world of machine learning,
|
||||
@@ -1074,14 +1060,10 @@ namespace Learner
|
||||
// display mse (this is sometimes done only for thread 0)
|
||||
// Immediately after being read from the file...
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
// Lock the evaluation function so that it is not used during updating.
|
||||
shared_lock<shared_timed_mutex> read_lock(nn_mutex, defer_lock);
|
||||
if (sr.next_update_weights <= sr.total_done ||
|
||||
(thread_id != 0 && !read_lock.try_lock()))
|
||||
#else
|
||||
if (sr.next_update_weights <= sr.total_done)
|
||||
#endif
|
||||
{
|
||||
if (thread_id != 0)
|
||||
{
|
||||
@@ -1105,18 +1087,6 @@ namespace Learner
|
||||
continue;
|
||||
}
|
||||
|
||||
#if !defined(EVAL_NNUE)
|
||||
// Output the current time. Output every time.
|
||||
std::cout << sr.total_done << " sfens , at " << now_string() << std::endl;
|
||||
|
||||
// Reflect the gradient in the weight array at this timing.
|
||||
// The calculation of the gradient is just right for
|
||||
// each 1M phase in terms of mini-batch.
|
||||
Eval::update_weights(epoch, freeze);
|
||||
|
||||
// Display epoch and current eta for debugging.
|
||||
std::cout << "epoch = " << epoch << " , eta = " << Eval::get_eta() << std::endl;
|
||||
#else
|
||||
{
|
||||
// update parameters
|
||||
|
||||
@@ -1124,7 +1094,7 @@ namespace Learner
|
||||
lock_guard<shared_timed_mutex> write_lock(nn_mutex);
|
||||
Eval::NNUE::UpdateParameters(epoch);
|
||||
}
|
||||
#endif
|
||||
|
||||
++epoch;
|
||||
|
||||
// However, the elapsed time during update_weights() and calc_rmse() is ignored.
|
||||
@@ -1156,9 +1126,7 @@ namespace Learner
|
||||
// loss calculation
|
||||
calc_loss(thread_id, done);
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
Eval::NNUE::CheckHealth();
|
||||
#endif
|
||||
|
||||
// Make a note of how far you have totaled.
|
||||
sr.last_done = sr.total_done;
|
||||
@@ -1216,25 +1184,6 @@ namespace Learner
|
||||
goto RETRY_READ;
|
||||
}
|
||||
|
||||
#if !defined(EVAL_NNUE)
|
||||
if (skip_duplicated_positions_in_training)
|
||||
{
|
||||
const auto key = pos.key();
|
||||
|
||||
// Exclude the phase used for rmse calculation.
|
||||
if (sr.is_for_rmse(key))
|
||||
goto RETRY_READ;
|
||||
|
||||
// Exclude the most recently used aspect.
|
||||
const auto hash_index = size_t(key & (sr.READ_SFEN_HASH_SIZE - 1));
|
||||
const auto key2 = sr.hash[hash_index];
|
||||
if (key == key2)
|
||||
goto RETRY_READ;
|
||||
|
||||
sr.hash[hash_index] = key; // Replace with the current key.
|
||||
}
|
||||
#endif
|
||||
|
||||
// There is a possibility that all the pieces are blocked and stuck.
|
||||
// Also, the declaration win phase is excluded from
|
||||
// learning because you cannot go to leaf with PV moves.
|
||||
@@ -1326,25 +1275,9 @@ namespace Learner
|
||||
learn_sum_entropy += learn_entropy;
|
||||
#endif
|
||||
|
||||
#if !defined(EVAL_NNUE)
|
||||
// Slope
|
||||
double dj_dw = calc_grad(deep_value, shallow_value, ps);
|
||||
|
||||
// Add jd_dw as the gradient (∂J/∂Wj) for the
|
||||
// feature vector currently appearing in the leaf node.
|
||||
|
||||
// If it is not PV termination, apply a discount rate.
|
||||
if (discount_rate != 0 && ply != (int)pv.size())
|
||||
dj_dw *= discount_rate;
|
||||
|
||||
// Since we have reached leaf, add the gradient to the features that appear in this phase.
|
||||
// Update based on gradient later.
|
||||
Eval::add_grad(pos, rootColor, dj_dw, freeze);
|
||||
#else
|
||||
const double example_weight =
|
||||
(discount_rate != 0 && ply != (int)pv.size()) ? discount_rate : 1.0;
|
||||
Eval::NNUE::AddExample(pos, rootColor, ps, example_weight);
|
||||
#endif
|
||||
|
||||
// Since the processing is completed, the counter of the processed number is incremented
|
||||
sr.total_done++;
|
||||
@@ -1425,7 +1358,6 @@ namespace Learner
|
||||
const std::string dir_name = std::to_string(dir_number++);
|
||||
Eval::save_eval(dir_name);
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
if (newbob_decay != 1.0 && latest_loss_count > 0) {
|
||||
static int trials = newbob_num_trials;
|
||||
const double latest_loss = latest_loss_sum / latest_loss_count;
|
||||
@@ -1470,7 +1402,6 @@ namespace Learner
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1817,12 +1748,10 @@ namespace Learner
|
||||
// Optional item that does not let you learn KK/KKP/KPP/KPPP
|
||||
array<bool, 4> freeze = {};
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
uint64_t nn_batch_size = 1000;
|
||||
double newbob_decay = 1.0;
|
||||
int newbob_num_trials = 2;
|
||||
string nn_options;
|
||||
#endif
|
||||
|
||||
uint64_t eval_save_interval = LEARN_EVAL_SAVE_INTERVAL;
|
||||
uint64_t loss_output_interval = 0;
|
||||
@@ -1922,12 +1851,11 @@ namespace Learner
|
||||
else if (option == "save_only_once") save_only_once = true;
|
||||
else if (option == "no_shuffle") no_shuffle = true;
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
else if (option == "nn_batch_size") is >> nn_batch_size;
|
||||
else if (option == "newbob_decay") is >> newbob_decay;
|
||||
else if (option == "newbob_num_trials") is >> newbob_num_trials;
|
||||
else if (option == "nn_options") is >> nn_options;
|
||||
#endif
|
||||
|
||||
else if (option == "eval_save_interval") is >> eval_save_interval;
|
||||
else if (option == "loss_output_interval") is >> loss_output_interval;
|
||||
else if (option == "mirror_percentage") is >> mirror_percentage;
|
||||
@@ -2074,23 +2002,18 @@ namespace Learner
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(EVAL_NNUE)
|
||||
cout << "Gradient Method : " << LEARN_UPDATE << endl;
|
||||
#endif
|
||||
cout << "Loss Function : " << LOSS_FUNCTION << endl;
|
||||
cout << "mini-batch size : " << mini_batch_size << endl;
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
cout << "nn_batch_size : " << nn_batch_size << endl;
|
||||
cout << "nn_options : " << nn_options << endl;
|
||||
#endif
|
||||
|
||||
cout << "learning rate : " << eta1 << " , " << eta2 << " , " << eta3 << endl;
|
||||
cout << "eta_epoch : " << eta1_epoch << " , " << eta2_epoch << endl;
|
||||
cout << "use_draw_games_in_training : " << use_draw_games_in_training << endl;
|
||||
cout << "use_draw_games_in_validation : " << use_draw_games_in_validation << endl;
|
||||
cout << "skip_duplicated_positions_in_training : " << skip_duplicated_positions_in_training << endl;
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
if (newbob_decay != 1.0) {
|
||||
cout << "scheduling : newbob with decay = " << newbob_decay
|
||||
<< ", " << newbob_num_trials << " trials" << endl;
|
||||
@@ -2098,7 +2021,6 @@ namespace Learner
|
||||
else {
|
||||
cout << "scheduling : default" << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
cout << "discount rate : " << discount_rate << endl;
|
||||
|
||||
@@ -2133,12 +2055,6 @@ namespace Learner
|
||||
// Read evaluation function parameters
|
||||
Eval::init_NNUE();
|
||||
|
||||
#if !defined(EVAL_NNUE)
|
||||
cout << "init_grad.." << endl;
|
||||
|
||||
// Initialize gradient array of merit function parameters
|
||||
Eval::init_grad(eta1, eta1_epoch, eta2, eta2_epoch, eta3);
|
||||
#else
|
||||
cout << "init_training.." << endl;
|
||||
Eval::NNUE::InitializeTraining(eta1, eta1_epoch, eta2, eta2_epoch, eta3);
|
||||
Eval::NNUE::SetBatchSize(nn_batch_size);
|
||||
@@ -2146,7 +2062,6 @@ namespace Learner
|
||||
if (newbob_decay != 1.0 && !Options["SkipLoadingEval"]) {
|
||||
learn_think.best_nn_directory = std::string(Options["EvalDir"]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// A test to give a gradient of 1.0 to the initial stage of Hirate.
|
||||
@@ -2170,11 +2085,9 @@ namespace Learner
|
||||
learn_think.freeze = freeze;
|
||||
learn_think.reduction_gameply = reduction_gameply;
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
learn_think.newbob_scale = 1.0;
|
||||
learn_think.newbob_decay = newbob_decay;
|
||||
learn_think.newbob_num_trials = newbob_num_trials;
|
||||
#endif
|
||||
|
||||
learn_think.eval_save_interval = eval_save_interval;
|
||||
learn_think.loss_output_interval = loss_output_interval;
|
||||
@@ -2199,7 +2112,6 @@ namespace Learner
|
||||
// Calculate rmse once at this point (timing of 0 sfen)
|
||||
// sr.calc_rmse();
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
if (newbob_decay != 1.0) {
|
||||
learn_think.calc_loss(0, -1);
|
||||
learn_think.best_loss = learn_think.latest_loss_sum / learn_think.latest_loss_count;
|
||||
@@ -2207,7 +2119,6 @@ namespace Learner
|
||||
learn_think.latest_loss_count = 0;
|
||||
cout << "initial loss: " << learn_think.best_loss << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// -----------------------------------
|
||||
// start learning evaluation function parameters
|
||||
|
||||
@@ -184,13 +184,11 @@ namespace Eval::NNUE {
|
||||
|
||||
Initialize();
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
if (Options["SkipLoadingEval"])
|
||||
{
|
||||
std::cout << "info string SkipLoadingEval set to true, Net not loaded!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
fileName = evalFile;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code for learning NNUE evaluation function
|
||||
|
||||
#if defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include <random>
|
||||
#include <fstream>
|
||||
@@ -229,4 +229,4 @@ double get_eta() {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#endif // defined(EVAL_LEARN)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef _EVALUATE_NNUE_LEARNER_H_
|
||||
#define _EVALUATE_NNUE_LEARNER_H_
|
||||
|
||||
#if defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include "../learn/learn.h"
|
||||
|
||||
@@ -41,6 +41,6 @@ void CheckHealth();
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#endif // defined(EVAL_LEARN)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
//Definition of input feature quantity K of NNUE evaluation function
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "castling_right.h"
|
||||
#include "index_list.h"
|
||||
|
||||
@@ -69,5 +67,3 @@ namespace Eval {
|
||||
} // namespace NNUE
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef _NNUE_FEATURES_CASTLING_RIGHT_H_
|
||||
#define _NNUE_FEATURES_CASTLING_RIGHT_H_
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "../../evaluate.h"
|
||||
#include "features_common.h"
|
||||
|
||||
@@ -43,6 +41,4 @@ namespace Eval {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
//Definition of input feature quantity K of NNUE evaluation function
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "enpassant.h"
|
||||
#include "index_list.h"
|
||||
|
||||
@@ -43,5 +41,3 @@ namespace Eval {
|
||||
} // namespace NNUE
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef _NNUE_FEATURES_ENPASSANT_H_
|
||||
#define _NNUE_FEATURES_ENPASSANT_H_
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "../../evaluate.h"
|
||||
#include "features_common.h"
|
||||
|
||||
@@ -43,6 +41,4 @@ namespace Eval {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
//Definition of input features HalfRelativeKP of NNUE evaluation function
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "half_relative_kp.h"
|
||||
#include "index_list.h"
|
||||
|
||||
@@ -74,5 +72,3 @@ template class HalfRelativeKP<Side::kEnemy>;
|
||||
} // namespace NNUE
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef _NNUE_FEATURES_HALF_RELATIVE_KP_H_
|
||||
#define _NNUE_FEATURES_HALF_RELATIVE_KP_H_
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "../../evaluate.h"
|
||||
#include "features_common.h"
|
||||
|
||||
@@ -60,6 +58,4 @@ class HalfRelativeKP {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
//Definition of input feature quantity K of NNUE evaluation function
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "k.h"
|
||||
#include "index_list.h"
|
||||
|
||||
@@ -54,5 +52,3 @@ void K::AppendChangedIndices(
|
||||
} // namespace NNUE
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef _NNUE_FEATURES_K_H_
|
||||
#define _NNUE_FEATURES_K_H_
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "../../evaluate.h"
|
||||
#include "features_common.h"
|
||||
|
||||
@@ -47,6 +45,4 @@ private:
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
//Definition of input feature P of NNUE evaluation function
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "p.h"
|
||||
#include "index_list.h"
|
||||
|
||||
@@ -52,5 +50,3 @@ void P::AppendChangedIndices(
|
||||
} // namespace NNUE
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef _NNUE_FEATURES_P_H_
|
||||
#define _NNUE_FEATURES_P_H_
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "../../evaluate.h"
|
||||
#include "features_common.h"
|
||||
|
||||
@@ -47,6 +45,4 @@ class P {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef _NNUE_LAYERS_SUM_H_
|
||||
#define _NNUE_LAYERS_SUM_H_
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "../nnue_common.h"
|
||||
|
||||
namespace Eval {
|
||||
@@ -158,6 +156,4 @@ class Sum<PreviousLayer> {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// USI extended command for NNUE evaluation function
|
||||
|
||||
#if defined(ENABLE_TEST_CMD) && defined(EVAL_NNUE)
|
||||
#if defined(ENABLE_TEST_CMD)
|
||||
|
||||
#include "../thread.h"
|
||||
#include "../uci.h"
|
||||
@@ -198,4 +198,4 @@ void TestCommand(Position& pos, std::istream& stream) {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(ENABLE_TEST_CMD) && defined(EVAL_NNUE)
|
||||
#endif // defined(ENABLE_TEST_CMD)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef _NNUE_TEST_COMMAND_H_
|
||||
#define _NNUE_TEST_COMMAND_H_
|
||||
|
||||
#if defined(ENABLE_TEST_CMD) && defined(EVAL_NNUE)
|
||||
#if defined(ENABLE_TEST_CMD)
|
||||
|
||||
namespace Eval {
|
||||
|
||||
@@ -16,6 +16,6 @@ void TestCommand(Position& pos, std::istream& stream);
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(ENABLE_TEST_CMD) && defined(EVAL_NNUE)
|
||||
#endif // defined(ENABLE_TEST_CMD)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef _NNUE_TRAINER_FEATURES_FACTORIZER_H_
|
||||
#define _NNUE_TRAINER_FEATURES_FACTORIZER_H_
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "../../nnue_common.h"
|
||||
#include "../trainer.h"
|
||||
|
||||
@@ -105,6 +103,4 @@ constexpr std::size_t GetArrayLength(const T (&/*array*/)[N]) {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef _NNUE_TRAINER_FEATURES_FACTORIZER_FEATURE_SET_H_
|
||||
#define _NNUE_TRAINER_FEATURES_FACTORIZER_FEATURE_SET_H_
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "../../features/feature_set.h"
|
||||
#include "factorizer.h"
|
||||
|
||||
@@ -99,6 +97,4 @@ public:
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef _NNUE_TRAINER_FEATURES_FACTORIZER_HALF_KP_H_
|
||||
#define _NNUE_TRAINER_FEATURES_FACTORIZER_HALF_KP_H_
|
||||
|
||||
#if defined(EVAL_NNUE)
|
||||
|
||||
#include "../../features/half_kp.h"
|
||||
#include "../../features/p.h"
|
||||
#include "../../features/half_relative_kp.h"
|
||||
@@ -98,6 +96,4 @@ constexpr FeatureProperties Factorizer<HalfKP<AssociatedKing>>::kProperties[];
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_NNUE)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef _NNUE_TRAINER_H_
|
||||
#define _NNUE_TRAINER_H_
|
||||
|
||||
#if defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include "../nnue_common.h"
|
||||
#include "../features/index_list.h"
|
||||
@@ -120,6 +120,6 @@ std::shared_ptr<T> MakeAlignedSharedPtr(ArgumentTypes&&... arguments) {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#endif // defined(EVAL_LEARN)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef _NNUE_TRAINER_AFFINE_TRANSFORM_H_
|
||||
#define _NNUE_TRAINER_AFFINE_TRANSFORM_H_
|
||||
|
||||
#if defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include "../../learn/learn.h"
|
||||
#include "../layers/affine_transform.h"
|
||||
@@ -296,6 +296,6 @@ class Trainer<Layers::AffineTransform<PreviousLayer, OutputDimensions>> {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#endif // defined(EVAL_LEARN)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef _NNUE_TRAINER_CLIPPED_RELU_H_
|
||||
#define _NNUE_TRAINER_CLIPPED_RELU_H_
|
||||
|
||||
#if defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include "../../learn/learn.h"
|
||||
#include "../layers/clipped_relu.h"
|
||||
@@ -137,6 +137,6 @@ class Trainer<Layers::ClippedReLU<PreviousLayer>> {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#endif // defined(EVAL_LEARN)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef _NNUE_TRAINER_FEATURE_TRANSFORMER_H_
|
||||
#define _NNUE_TRAINER_FEATURE_TRANSFORMER_H_
|
||||
|
||||
#if defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include "../../learn/learn.h"
|
||||
#include "../nnue_feature_transformer.h"
|
||||
@@ -372,6 +372,6 @@ class Trainer<FeatureTransformer> {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#endif // defined(EVAL_LEARN)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef _NNUE_TRAINER_INPUT_SLICE_H_
|
||||
#define _NNUE_TRAINER_INPUT_SLICE_H_
|
||||
|
||||
#if defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include "../../learn/learn.h"
|
||||
#include "../layers/input_slice.h"
|
||||
@@ -246,6 +246,6 @@ class Trainer<Layers::InputSlice<OutputDimensions, Offset>> {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#endif // defined(EVAL_LEARN)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef _NNUE_TRAINER_SUM_H_
|
||||
#define _NNUE_TRAINER_SUM_H_
|
||||
|
||||
#if defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include "../../learn/learn.h"
|
||||
#include "../layers/sum.h"
|
||||
@@ -185,6 +185,6 @@ class Trainer<Layers::Sum<PreviousLayer>> {
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE)
|
||||
#endif // defined(EVAL_LEARN)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "uci.h"
|
||||
#include "syzygy/tbprobe.h"
|
||||
|
||||
#if defined(EVAL_NNUE) && defined(ENABLE_TEST_CMD)
|
||||
#if defined(ENABLE_TEST_CMD)
|
||||
#include "nnue/nnue_test_command.h"
|
||||
#endif
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Learner
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(EVAL_NNUE) && defined(ENABLE_TEST_CMD)
|
||||
#if defined(ENABLE_TEST_CMD)
|
||||
void test_cmd(Position& pos, istringstream& is)
|
||||
{
|
||||
// Initialize as it may be searched.
|
||||
@@ -373,7 +373,7 @@ void UCI::loop(int argc, char* argv[]) {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(EVAL_NNUE) && defined(ENABLE_TEST_CMD)
|
||||
#if defined(ENABLE_TEST_CMD)
|
||||
// test command
|
||||
else if (token == "test") test_cmd(pos, is);
|
||||
#endif
|
||||
|
||||
@@ -83,7 +83,6 @@ void init(OptionsMap& o) {
|
||||
// The default must follow the format nn-[SHA256 first 12 digits].nnue
|
||||
// for the build process (profile-build and fishtest) to work.
|
||||
o["EvalFile"] << Option("nn-82215d0fd0df.nnue", on_eval_file);
|
||||
#ifdef EVAL_NNUE
|
||||
// When the evaluation function is loaded at the ucinewgame timing, it is necessary to convert the new evaluation function.
|
||||
// I want to hit the test eval convert command, but there is no new evaluation function
|
||||
// It ends abnormally before executing this command.
|
||||
@@ -92,7 +91,6 @@ void init(OptionsMap& o) {
|
||||
o["SkipLoadingEval"] << Option(false);
|
||||
// how many moves to use a fixed move
|
||||
// o["BookMoves"] << Option(16, 0, 10000);
|
||||
#endif
|
||||
#if defined(EVAL_LEARN)
|
||||
// When learning the evaluation function, you can change the folder to save the evaluation function.
|
||||
// Evalsave by default. This folder shall be prepared in advance.
|
||||
|
||||
Reference in New Issue
Block a user