Guard against index error in prediction. (#6982)
* Remove `best_ntree_limit` from documents.
This commit is contained in:
@@ -501,6 +501,7 @@ void GBTree::PredictBatch(DMatrix* p_fmat,
|
||||
uint32_t tree_begin, tree_end;
|
||||
std::tie(tree_begin, tree_end) =
|
||||
detail::LayerToTree(model_, tparam_, layer_begin, layer_end);
|
||||
CHECK_LE(tree_end, model_.trees.size()) << "Invalid number of trees.";
|
||||
if (tree_end > tree_begin) {
|
||||
predictor->PredictBatch(p_fmat, out_preds, model_, tree_begin, tree_end);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user