mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-24 02:57:11 +08:00
Use plain nnue eval for validation loss calculation instead of first performing qsearch
This commit is contained in:
@@ -611,8 +611,6 @@ namespace Learner
|
|||||||
atomic<int>& move_accord_count
|
atomic<int>& move_accord_count
|
||||||
);
|
);
|
||||||
|
|
||||||
Value get_shallow_value(Position& pos);
|
|
||||||
|
|
||||||
bool check_progress();
|
bool check_progress();
|
||||||
|
|
||||||
// save merit function parameters to a file
|
// save merit function parameters to a file
|
||||||
@@ -996,7 +994,7 @@ namespace Learner
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Value shallow_value = get_shallow_value(pos);
|
const Value shallow_value = Eval::evaluate(pos);
|
||||||
|
|
||||||
// Evaluation value of deep search
|
// Evaluation value of deep search
|
||||||
const auto deep_value = (Value)ps.score;
|
const auto deep_value = (Value)ps.score;
|
||||||
@@ -1018,33 +1016,6 @@ namespace Learner
|
|||||||
test_loss_sum += local_loss_sum;
|
test_loss_sum += local_loss_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value LearnerThink::get_shallow_value(Position& pos)
|
|
||||||
{
|
|
||||||
// Evaluation value for shallow search
|
|
||||||
// The value of evaluate() may be used, but when calculating loss, learn_cross_entropy and
|
|
||||||
// Use qsearch() because it is difficult to compare the values.
|
|
||||||
// EvalHash has been disabled in advance. (If not, the same value will be returned every time)
|
|
||||||
const auto [_, pv] = Search::qsearch(pos);
|
|
||||||
|
|
||||||
const auto rootColor = pos.side_to_move();
|
|
||||||
|
|
||||||
std::vector<StateInfo, AlignedAllocator<StateInfo>> states(pv.size());
|
|
||||||
for (size_t i = 0; i < pv.size(); ++i)
|
|
||||||
{
|
|
||||||
pos.do_move(pv[i], states[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Value shallow_value =
|
|
||||||
(rootColor == pos.side_to_move())
|
|
||||||
? Eval::evaluate(pos)
|
|
||||||
: -Eval::evaluate(pos);
|
|
||||||
|
|
||||||
for (auto it = pv.rbegin(); it != pv.rend(); ++it)
|
|
||||||
pos.undo_move(*it);
|
|
||||||
|
|
||||||
return shallow_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LearnerThink::check_progress()
|
bool LearnerThink::check_progress()
|
||||||
{
|
{
|
||||||
auto out = sync_region_cout.new_region();
|
auto out = sync_region_cout.new_region();
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ cat << EOF > learn01.exp
|
|||||||
|
|
||||||
send "uci\n"
|
send "uci\n"
|
||||||
send "setoption name SkipLoadingEval value true\n"
|
send "setoption name SkipLoadingEval value true\n"
|
||||||
send "setoption name Use NNUE value true\n"
|
send "setoption name Use NNUE value pure\n"
|
||||||
send "setoption name Threads value $threads\n"
|
send "setoption name Threads value $threads\n"
|
||||||
send "isready\n"
|
send "isready\n"
|
||||||
send "learn targetdir training_data epochs 1 sfen_read_size 100 thread_buffer_size 10 batchsize 100 use_draw_in_training 1 use_draw_in_validation 1 lr 1 eval_limit 32000 nn_batch_size 30 newbob_decay 0.5 eval_save_interval 30 loss_output_interval 10 validation_set_file_name validation_data/validation_data.bin\n"
|
send "learn targetdir training_data epochs 1 sfen_read_size 100 thread_buffer_size 10 batchsize 100 use_draw_in_training 1 use_draw_in_validation 1 lr 1 eval_limit 32000 nn_batch_size 30 newbob_decay 0.5 eval_save_interval 30 loss_output_interval 10 validation_set_file_name validation_data/validation_data.bin\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user