Commit 2f984f3a authored by Allard van Mossel's avatar Allard van Mossel Committed by Guolin Ke
Browse files

Fixed bug when num_iterations > early_stopping_round (#50)

parent b24190a6
......@@ -217,9 +217,9 @@ void GBDT::Train() {
}
}
// close file
if (early_stopping_round_ > 0) {
// save remaining models
for (int iter = gbdt_config_->num_iterations - early_stopping_round_; iter < static_cast<int>(models_.size()); ++iter){
int remaining_models = gbdt_config_->num_iterations - early_stopping_round_;
if (early_stopping_round_ > 0 && remaining_models > 0) {
for (int iter = remaining_models; iter < static_cast<int>(models_.size()); ++iter){
fprintf(output_model_file, "Tree=%d\n", iter);
fprintf(output_model_file, "%s\n", models_.at(iter)->ToString().c_str());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment