10 #ifndef META_BATCH_TRAINING_H_
11 #define META_BATCH_TRAINING_H_
38 template <
class Index,
class Classifier>
40 const std::vector<doc_id>& training_set, uint64_t batch_size)
42 auto docs = training_set;
43 std::mt19937 gen(std::random_device{}());
44 std::shuffle(docs.begin(), docs.end(), gen);
47 auto num_batches = (docs.size() + batch_size - 1) / batch_size;
48 for (uint64_t i = 0; i < num_batches; ++i)
50 LOG(progress) <<
"\rTraining batch " << i + 1 <<
"/" << num_batches
52 auto end = std::min<uint64_t>((i + 1) * batch_size, docs.size());
53 std::vector<doc_id> batch{docs.begin() + (i * batch_size),
58 LOG(progress) <<
'\n' << ENDLG;