MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / ResetConfig

Method ResetConfig

src/treelearner/serial_tree_learner.cpp:141–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141void SerialTreeLearner::ResetConfig(const Config* config) {
142 if (config_->num_leaves != config->num_leaves) {
143 config_ = config;
144 int max_cache_size = 0;
145 // Get the max size of pool
146 if (config->histogram_pool_size <= 0) {
147 max_cache_size = config_->num_leaves;
148 } else {
149 size_t total_histogram_size = 0;
150 for (int i = 0; i < train_data_->num_features(); ++i) {
151 total_histogram_size += sizeof(HistogramBinEntry) * train_data_->FeatureNumBin(i);
152 }
153 max_cache_size = static_cast<int>(config_->histogram_pool_size * 1024 * 1024 / total_histogram_size);
154 }
155 // at least need 2 leaves
156 max_cache_size = std::max(2, max_cache_size);
157 max_cache_size = std::min(max_cache_size, config_->num_leaves);
158 histogram_pool_.DynamicChangeSize(train_data_, config_, max_cache_size, config_->num_leaves);
159
160 // push split information for all leaves
161 best_split_per_leaf_.resize(config_->num_leaves);
162 data_partition_->ResetLeaves(config_->num_leaves);
163 } else {
164 config_ = config;
165 }
166 histogram_pool_.ResetConfig(config_);
167 if (CostEfficientGradientBoosting::IsEnable(config_)) {
168 cegb_.reset(new CostEfficientGradientBoosting(this));
169 cegb_->Init();
170 }
171}
172
173Tree* SerialTreeLearner::Train(const score_t* gradients, const score_t *hessians, bool is_constant_hessian, const Json& forced_split_json) {
174 gradients_ = gradients;

Callers

nothing calls this directly

Calls 7

resetMethod · 0.80
num_featuresMethod · 0.45
FeatureNumBinMethod · 0.45
DynamicChangeSizeMethod · 0.45
resizeMethod · 0.45
ResetLeavesMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected