add logging
This commit is contained in:
parent
7301022fed
commit
60a3bea7c6
@ -61,6 +61,8 @@
|
|||||||
#include "xgboost/predictor.h" // for PredictionContainer, PredictionCacheEntry
|
#include "xgboost/predictor.h" // for PredictionContainer, PredictionCacheEntry
|
||||||
#include "xgboost/string_view.h" // for operator<<, StringView
|
#include "xgboost/string_view.h" // for operator<<, StringView
|
||||||
#include "xgboost/task.h" // for ObjInfo
|
#include "xgboost/task.h" // for ObjInfo
|
||||||
|
#include <iostream>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const char* kMaxDeltaStepDefaultValue = "0.7";
|
const char* kMaxDeltaStepDefaultValue = "0.7";
|
||||||
@ -1262,34 +1264,57 @@ class LearnerImpl : public LearnerIO {
|
|||||||
return out_impl;
|
return out_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateOneIter(int iter, std::shared_ptr<DMatrix> train) override {
|
void UpdateOneIter(int iter, std::shared_ptr<DMatrix> train) override {
|
||||||
monitor_.Start("UpdateOneIter");
|
std::cerr << "Entering UpdateOneIter, iteration: " << iter << std::endl;
|
||||||
TrainingObserver::Instance().Update(iter);
|
monitor_.Start("UpdateOneIter");
|
||||||
this->Configure();
|
TrainingObserver::Instance().Update(iter);
|
||||||
this->InitBaseScore(train.get());
|
|
||||||
|
|
||||||
if (ctx_.seed_per_iteration) {
|
std::cerr << "Configuring..." << std::endl;
|
||||||
common::GlobalRandom().seed(ctx_.seed * kRandSeedMagic + iter);
|
this->Configure();
|
||||||
}
|
|
||||||
|
|
||||||
this->ValidateDMatrix(train.get(), true);
|
std::cerr << "Initializing base score..." << std::endl;
|
||||||
|
this->InitBaseScore(train.get());
|
||||||
|
|
||||||
auto& predt = prediction_container_.Cache(train, ctx_.Device());
|
if (ctx_.seed_per_iteration) {
|
||||||
|
std::cerr << "Setting seed for iteration..." << std::endl;
|
||||||
monitor_.Start("PredictRaw");
|
common::GlobalRandom().seed(ctx_.seed * kRandSeedMagic + iter);
|
||||||
this->PredictRaw(train.get(), &predt, true, 0, 0);
|
|
||||||
TrainingObserver::Instance().Observe(predt.predictions, "Predictions");
|
|
||||||
monitor_.Stop("PredictRaw");
|
|
||||||
|
|
||||||
monitor_.Start("GetGradient");
|
|
||||||
GetGradient(predt.predictions, train->Info(), iter, &gpair_);
|
|
||||||
monitor_.Stop("GetGradient");
|
|
||||||
TrainingObserver::Instance().Observe(*gpair_.Data(), "Gradients");
|
|
||||||
|
|
||||||
gbm_->DoBoost(train.get(), &gpair_, &predt, obj_.get());
|
|
||||||
monitor_.Stop("UpdateOneIter");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cerr << "Validating DMatrix..." << std::endl;
|
||||||
|
this->ValidateDMatrix(train.get(), true);
|
||||||
|
|
||||||
|
std::cerr << "Caching predictions..." << std::endl;
|
||||||
|
auto& predt = prediction_container_.Cache(train, ctx_.Device());
|
||||||
|
|
||||||
|
monitor_.Start("PredictRaw");
|
||||||
|
std::cerr << "Predicting raw values..." << std::endl;
|
||||||
|
this->PredictRaw(train.get(), &predt, true, 0, 0);
|
||||||
|
TrainingObserver::Instance().Observe(predt.predictions, "Predictions");
|
||||||
|
monitor_.Stop("PredictRaw");
|
||||||
|
|
||||||
|
monitor_.Start("GetGradient");
|
||||||
|
std::cerr << "Getting gradients..." << std::endl;
|
||||||
|
try {
|
||||||
|
GetGradient(predt.predictions, train->Info(), iter, &gpair_);
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "Exception in GetGradient: " << e.what() << std::endl;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
monitor_.Stop("GetGradient");
|
||||||
|
TrainingObserver::Instance().Observe(*gpair_.Data(), "Gradients");
|
||||||
|
|
||||||
|
std::cerr << "Performing boosting..." << std::endl;
|
||||||
|
try {
|
||||||
|
gbm_->DoBoost(train.get(), &gpair_, &predt, obj_.get());
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "Exception in DoBoost: " << e.what() << std::endl;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor_.Stop("UpdateOneIter");
|
||||||
|
std::cerr << "Exiting UpdateOneIter" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void BoostOneIter(int iter, std::shared_ptr<DMatrix> train,
|
void BoostOneIter(int iter, std::shared_ptr<DMatrix> train,
|
||||||
linalg::Matrix<GradientPair>* in_gpair) override {
|
linalg::Matrix<GradientPair>* in_gpair) override {
|
||||||
monitor_.Start("BoostOneIter");
|
monitor_.Start("BoostOneIter");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user