Why is the version
variable incremented twice within the loop in the provided code snippet? As a result, version
is always an even number at the beginning of each iteration? Then the number of boosting iterations is actually half of the specified param_.num_round
?
// load in data.
...
// initialize the learner.
...
// start training.
int32_t version = 0;
for (int i = version / 2; i < param_.num_round; ++i) {
if (version % 2 == 0) {
learner_->UpdateOneIter(i, dtrain);
version += 1;
}
...
version += 1;
}
// save model
...
Why don’t we simply use the following logic? Why do we need the version
variable? What’s it for?
// load in data.
...
// initialize the learner.
...
// start training.
for (int i = 0; i < param_.num_round; ++i) {
learner_->UpdateOneIter(i, dtrain);
}
// save model
...
or
// load in data.
...
// initialize the learner.
...
// start training.
for (int i = 0; i < param_.num_round/2; ++i) {
learner_->UpdateOneIter(i, dtrain);
}
// save model
...