Skip to content

Commit 8203306

Browse files
authored
Fix updates in random forest model using GOSS data sample strategy (#6017)
1 parent 5ea0057 commit 8203306

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/boosting/rf.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ class RF : public GBDT {
115115
const data_size_t bag_data_cnt = data_sample_strategy_->bag_data_cnt();
116116
const std::vector<data_size_t, Common::AlignmentAllocator<data_size_t, kAlignedSize>>& bag_data_indices = data_sample_strategy_->bag_data_indices();
117117

118+
// GOSSStrategy->Bagging may modify value of bag_data_cnt_
119+
if (is_use_subset && bag_data_cnt < num_data_) {
120+
tmp_grad_.resize(num_data_);
121+
tmp_hess_.resize(num_data_);
122+
}
123+
118124
CHECK_EQ(gradients, nullptr);
119125
CHECK_EQ(hessians, nullptr);
120126

0 commit comments

Comments
 (0)