| 280 | } |
| 281 | |
| 282 | void Metadata::SetInitScore(const double* init_score, data_size_t len) { |
| 283 | std::lock_guard<std::mutex> lock(mutex_); |
| 284 | // save to nullptr |
| 285 | if (init_score == nullptr || len == 0) { |
| 286 | init_score_.clear(); |
| 287 | num_init_score_ = 0; |
| 288 | return; |
| 289 | } |
| 290 | if ((len % num_data_) != 0) { |
| 291 | Log::Fatal("Initial score size doesn't match data size"); |
| 292 | } |
| 293 | if (!init_score_.empty()) { init_score_.clear(); } |
| 294 | num_init_score_ = len; |
| 295 | init_score_ = std::vector<double>(len); |
| 296 | #pragma omp parallel for schedule(static) |
| 297 | for (int64_t i = 0; i < num_init_score_; ++i) { |
| 298 | init_score_[i] = Common::AvoidInf(init_score[i]); |
| 299 | } |
| 300 | init_score_load_from_file_ = false; |
| 301 | } |
| 302 | |
| 303 | void Metadata::SetLabel(const label_t* label, data_size_t len) { |
| 304 | std::lock_guard<std::mutex> lock(mutex_); |
no test coverage detected