Skip to content

Commit

Permalink
Load configuration before loading model.
Browse files Browse the repository at this point in the history
Initialize the context before loading model.
  • Loading branch information
trivialfis committed Sep 20, 2023
1 parent 0080c97 commit 3f3f756
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/gbm/gbtree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,7 @@ void GBTree::SaveConfig(Json* p_out) const {
// e.g. updating a model, then saving and loading it would result in an empty
// model
out["gbtree_train_param"]["process_type"] = String("default");
// Duplicated from SaveModel so that user can get `num_parallel_tree` without parsing
// the model. We might remove this once we can deprecate `best_ntree_limit` so that the
// language binding doesn't need to know about the forest size.
// We save it for parameter validation. It's not loaded in `LoadConfig`.
out["gbtree_model_param"] = ToJson(model_.param);

out["updater"] = Array{};
Expand Down
2 changes: 1 addition & 1 deletion src/learner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,8 @@ class LearnerIO : public LearnerConfiguration {
// We should migrate to use `xgb.load.raw` instead.
this->LoadModel(memory_snapshot);
} else {
this->LoadModel(memory_snapshot["Model"]);
this->LoadConfig(memory_snapshot["Config"]);
this->LoadModel(memory_snapshot["Model"]);
}
} else {
std::string header;
Expand Down

0 comments on commit 3f3f756

Please sign in to comment.