Skip to content

Commit

Permalink
Modify GBTree config
Browse files Browse the repository at this point in the history
  • Loading branch information
RAMitchell committed Apr 7, 2020
1 parent 5a18d01 commit 56834db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/gbm/gbtree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ void GBTree::CommitModel(std::vector<std::vector<std::unique_ptr<RegTree>>>&& ne
void GBTree::LoadConfig(Json const& in) {
CHECK_EQ(get<String>(in["name"]), "gbtree");
fromJson(in["gbtree_train_param"], &tparam_);
// Process type cannot be kUpdate from loaded model
// This would cause all trees to be pushed to trees_to_update
// e.g. updating a model, then saving and loading it would result in an empty model
tparam_.process_type = TreeProcessType::kDefault;
int32_t const n_gpus = xgboost::common::AllVisibleGPUs();
if (n_gpus == 0 && tparam_.predictor == PredictorType::kGPUPredictor) {
LOG(WARNING)
Expand Down Expand Up @@ -348,6 +352,13 @@ void GBTree::SaveConfig(Json* p_out) const {
auto& out = *p_out;
out["name"] = String("gbtree");
out["gbtree_train_param"] = toJson(tparam_);

// Process type cannot be kUpdate from loaded model
// This would cause all trees to be pushed to trees_to_update
// e.g. updating a model, then saving and loading it would result in an empty
// model
out["gbtree_train_param"]["process_type"] = String("default");

out["updater"] = Object();

auto& j_updaters = out["updater"];
Expand Down
6 changes: 0 additions & 6 deletions src/learner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,6 @@ class LearnerIO : public LearnerConfiguration {
tparam_.dsplit = DataSplitMode::kRow;
}

// Do not load "process_type":"update", this causes all trees to be removed
// from the model on configuration
if (cfg_.find("process_type") == cfg_.end()) {
cfg_["process_type"] = "default";
}

this->Configure();
}

Expand Down

0 comments on commit 56834db

Please sign in to comment.