Check whether current updater can modify a tree. (#5406)

* Check whether current updater can modify a tree.

* Fix tree model JSON IO for pruned trees.
This commit is contained in:
Jiaming Yuan
2020-03-14 09:24:08 +08:00
committed by GitHub
parent b745b7acce
commit ab7a46a1a4
8 changed files with 99 additions and 4 deletions

View File

@@ -273,6 +273,12 @@ void GBTree::BoostNewTrees(HostDeviceVector<GradientPair>* gpair,
new_trees.push_back(ptr.get());
ret->push_back(std::move(ptr));
} else if (tparam_.process_type == TreeProcessType::kUpdate) {
for (auto const& up : updaters_) {
CHECK(up->CanModifyTree())
<< "Updater: `" << up->Name() << "` "
<< "can not be used to modify existing trees. "
<< "Set `process_type` to `default` if you want to build new trees.";
}
CHECK_LT(model_.trees.size(), model_.trees_to_update.size());
// move an existing tree from trees_to_update
auto t = std::move(model_.trees_to_update[model_.trees.size() +