MCPcopy Create free account
hub / github.com/dhbloo/rapfi / tuning

Method tuning

Rapfi/command/tuning.cpp:93–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91} // namespace
92
93void Command::tuning(int argc, char *argv[])
94{
95 std::string outdir;
96 std::string trainName;
97 size_t epochs;
98 size_t modelExportInterval;
99 TuningConfig cfg = {};
100 DatasetType trainDatasetType;
101 DatasetType valDatasetType;
102 std::vector<std::string> trainDatasetPathList;
103 std::vector<std::string> valDatasetPathList;
104 std::vector<std::string> extensions;
105 std::unique_ptr<Dataset> trainDataset, valDataset;
106
107 cxxopts::Options options("rapfi tuning");
108 options.add_options() //
109 ("o,output", "Output directory", cxxopts::value<std::string>()) //
110 ("n,name", "Name of the trained models", cxxopts::value<std::string>()) //
111 ("d,training-dataset",
112 "Training dataset filename/directory(s), plain or compressed",
113 cxxopts::value<std::vector<std::string>>()) //
114 ("v,validation-dataset",
115 "Validation dataset filename/directory(s), plain or compressed",
116 cxxopts::value<std::vector<std::string>>()) //
117 ("training-dataset-type",
118 "Input dataset type, one of [bin, binpack]",
119 cxxopts::value<std::string>()->default_value("binpack")) //
120 ("validation-dataset-type",
121 "Input dataset type, one of [bin, binpack]",
122 cxxopts::value<std::string>()->default_value("binpack")) //
123 ("e,epochs",
124 "Number of epochs to train",
125 cxxopts::value<size_t>()) //
126 ("i,export-interval",
127 "Number of epochs between model checkpoint saving (0 for no checkpoint)",
128 cxxopts::value<size_t>()->default_value("100")) //
129 ("b,batchsize",
130 "Number of samples in one gradient batch",
131 cxxopts::value<size_t>()->default_value(std::to_string(cfg.batchSize))) //
132 ("l,learning-rate",
133 "Learning rate for gradient descent",
134 cxxopts::value<double>()->default_value(std::to_string(cfg.learningRate))) //
135 ("w,weight-decay",
136 "Weight dacay for gradient descent (0.0~1.0)",
137 cxxopts::value<double>()->default_value(std::to_string(cfg.weightDecay))) //
138 ("L,loss",
139 "Loss type (one of [L1, L2, BCE])",
140 cxxopts::value<std::string>()->default_value("BCE")) //
141 ("r,rules-to-tune",
142 "Params of which rules [freestyle, standard, renju] that need to be tuned",
143 cxxopts::value<std::vector<std::string>>()->default_value("freestyle,standard,renju")) //
144 ("s,shuffle", "Shuffle training datasets") //
145 ("m,tune-move-score", "Enable tuning of move scores") //
146 ("no-tune-eval", "Disable tuning of evaluation") //
147 ("move-score-loss-gamma",
148 "Gamma value (>= 0) of move score focal loss",
149 cxxopts::value<double>()->default_value(std::to_string(cfg.moveScoreLossGamma))) //
150 ("move-score-scale",

Callers

nothing calls this directly

Calls 15

parseTuningRulesFunction · 0.85
parseLossTypeFunction · 0.85
validateConfigFunction · 0.85
ensureDirFunction · 0.85
makeFileListFromPathListFunction · 0.85
createDatasetFunction · 0.85
exportModelFunction · 0.85
add_optionsMethod · 0.80
default_valueMethod · 0.80
helpMethod · 0.80
whatMethod · 0.80
saveParamsMethod · 0.80

Tested by

no test coverage detected