Move the old convert stuff from learn to their own commands.

This commit is contained in:
Tomasz Sobczyk
2020-10-18 14:51:38 +02:00
committed by nodchip
parent f7530de20d
commit c7ac3688a7
4 changed files with 228 additions and 100 deletions

View File

@@ -19,7 +19,6 @@
#include "learn.h"
#include "convert.h"
#include "sfen_reader.h"
#include "misc.h"
@@ -940,29 +939,8 @@ namespace Learner
// Game file storage folder (get game file with relative path from here)
string base_dir;
string target_dir;
// --- Function that only shuffles the teacher aspect
// normal shuffle
// Conversion of packed sfen. In plain, it consists of sfen(string),
// evaluation value (integer), move (eg 7g7f, string), result (loss-1, win 1, draw 0)
bool use_convert_plain = false;
// convert plain format teacher to Yaneura King's bin
bool use_convert_bin = false;
int ply_minimum = 0;
int ply_maximum = 114514;
bool interpolate_eval = 0;
bool check_invalid_fen = false;
bool check_illegal_move = false;
// convert teacher in pgn-extract format to Yaneura King's bin
bool use_convert_bin_from_pgn_extract = false;
bool pgn_eval_side_to_move = false;
bool convert_no_eval_fens_as_score_zero = false;
// File name to write in those cases (default is "shuffled_sfen.bin")
string output_file_name = "shuffled_sfen.bin";
// If the absolute value of the evaluation value
// in the deep search of the teacher phase exceeds this value,
// that phase is discarded.
@@ -1079,19 +1057,11 @@ namespace Learner
else if (option == "loss_output_interval") is >> loss_output_interval;
else if (option == "validation_set_file_name") is >> validation_set_file_name;
// Rabbit convert related
else if (option == "convert_plain") use_convert_plain = true;
else if (option == "convert_bin") use_convert_bin = true;
else if (option == "interpolate_eval") is >> interpolate_eval;
else if (option == "check_invalid_fen") is >> check_invalid_fen;
else if (option == "check_illegal_move") is >> check_illegal_move;
else if (option == "convert_bin_from_pgn-extract") use_convert_bin_from_pgn_extract = true;
else if (option == "pgn_eval_side_to_move") is >> pgn_eval_side_to_move;
else if (option == "convert_no_eval_fens_as_score_zero") is >> convert_no_eval_fens_as_score_zero;
else if (option == "src_score_min_value") is >> src_score_min_value;
else if (option == "src_score_max_value") is >> src_score_max_value;
else if (option == "dest_score_min_value") is >> dest_score_min_value;
else if (option == "dest_score_max_value") is >> dest_score_max_value;
else if (option == "seed") is >> seed;
else if (option == "set_recommended_uci_options")
{
@@ -1123,8 +1093,8 @@ namespace Learner
cout << "Warning! OpenMP disabled." << endl;
#endif
LearnerThink learn_think(thread_num, seed);
// Right now we only have the individual files.
// We need to apply base_dir here
rebase_files(filenames, base_dir);
if (!target_dir.empty())
{
@@ -1144,48 +1114,6 @@ namespace Learner
cout << "base dir : " << base_dir << endl;
cout << "target dir : " << target_dir << endl;
if (use_convert_plain)
{
Eval::NNUE::init();
cout << "convert_plain.." << endl;
convert_plain(filenames, output_file_name);
return;
}
if (use_convert_bin)
{
Eval::NNUE::init();
cout << "convert_bin.." << endl;
convert_bin(
filenames,
output_file_name,
ply_minimum,
ply_maximum,
interpolate_eval,
src_score_min_value,
src_score_max_value,
dest_score_min_value,
dest_score_max_value,
check_invalid_fen,
check_illegal_move);
return;
}
if (use_convert_bin_from_pgn_extract)
{
Eval::NNUE::init();
cout << "convert_bin_from_pgn-extract.." << endl;
convert_bin_from_pgn_extract(
filenames,
output_file_name,
pgn_eval_side_to_move,
convert_no_eval_fens_as_score_zero);
return;
}
cout << "loop : " << loop << endl;
cout << "eval_limit : " << eval_limit << endl;
cout << "save_only_once : " << (save_only_once ? "true" : "false") << endl;
@@ -1226,6 +1154,8 @@ namespace Learner
cout << "init.." << endl;
LearnerThink learn_think(thread_num, seed);
Threads.main()->ponder = false;
set_learning_search_limits();
@@ -1244,8 +1174,6 @@ namespace Learner
Path::combine(Options["EvalSaveDir"], "original");
}
cout << "init done." << endl;
// Reflect other option settings.
learn_think.eval_limit = eval_limit;
learn_think.save_only_once = save_only_once;
@@ -1271,6 +1199,8 @@ namespace Learner
}
}
cout << "init done." << endl;
// Start learning.
learn_think.learn();
}