Go to the documentation of this file.
5 #ifndef XGBOOST_COMMON_OBSERVER_H_
6 #define XGBOOST_COMMON_OBSERVER_H_
20 #if defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
21 #define OBSERVER_PRINT LOG(INFO)
22 #define OBSERVER_ENDL ""
23 #define OBSERVER_NEWLINE ""
24 #else // defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
25 #define OBSERVER_PRINT std::cout << std::setprecision(17)
26 #define OBSERVER_ENDL std::endl
27 #define OBSERVER_NEWLINE "\n"
28 #endif // defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
39 #if defined(XGBOOST_USE_DEBUG_OUTPUT)
40 bool constexpr
static kObserve {
true};
42 bool constexpr
static kObserve {
false};
43 #endif // defined(XGBOOST_USE_DEBUG_OUTPUT)
63 auto const& tree = *p_tree;
68 size_t n = std::numeric_limits<std::size_t>::max()) {
69 std::vector<T> copy(span.
size());
70 std::copy(span.
cbegin(), span.
cend(), copy.begin());
75 void Observe(std::vector<T>
const& h_vec, std::string name,
76 size_t n = std::numeric_limits<std::size_t>::max())
const {
80 for (
size_t i = 0; i < h_vec.size(); ++i) {
82 if (i % 8 == 0 && i != 0) {
94 size_t n = std::numeric_limits<std::size_t>::max())
const {
101 size_t n = std::numeric_limits<std::size_t>::max())
const {
107 template <
typename Parameter,
108 typename std::enable_if<
109 std::is_base_of<XGBoostParameter<Parameter>, Parameter>::value>::type* =
nullptr>
110 void Observe(
const Parameter &p, std::string name)
const {
113 Json obj {toJson(p)};
120 for (
auto kv : args) {
133 #endif // XGBOOST_COMMON_OBSERVER_H_
void Update(int32_t iter) const
Definition: observer.h:46
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:265
void Observe(const Parameter &p, std::string name) const
Definition: observer.h:110
#define XGBOOST_EXPECT(cond, ret)
Definition: base.h:75
void Observe(std::vector< T > const &h_vec, std::string name, size_t n=std::numeric_limits< std::size_t >::max()) const
Definition: observer.h:75
void Observe(RegTree const &tree)
Definition: observer.h:51
static void Dump(Json json, std::string *out)
macro for using C++11 enum class as DMLC parameter
Definition: host_device_vector.h:86
A device-and-host vector abstraction layer.
static TrainingObserver & Instance()
Definition: observer.h:127
defines configuration macros of xgboost.
void Observe(Args const &args) const
Definition: observer.h:117
std::vector< T > & HostVector()
#define OBSERVER_ENDL
Definition: observer.h:26
void SaveModel(Json *out) const override
saves the model config to a JSON object
void Observe(HostDeviceVector< T > *vec, std::string name, size_t n=std::numeric_limits< std::size_t >::max()) const
Definition: observer.h:100
void Observe(HostDeviceVector< T > const &vec, std::string name, size_t n=std::numeric_limits< std::size_t >::max()) const
Definition: observer.h:93
#define OBSERVER_NEWLINE
Definition: observer.h:27
define regression tree to be the most common tree model. This is the data structure used in xgboost's...
Definition: tree_model.h:131
#define OBSERVER_PRINT
Definition: observer.h:25
void Observe(RegTree const *p_tree)
Definition: observer.h:61
Definition: observer.h:38
constexpr XGBOOST_DEVICE const_iterator cbegin() const __span_noexcept
Definition: span.h:499
constexpr XGBOOST_DEVICE index_type size() const __span_noexcept
Definition: span.h:547
JsonObject Object
Definition: json.h:561
constexpr XGBOOST_DEVICE const_iterator cend() const __span_noexcept
Definition: span.h:503
void Observe(common::Span< T > span, std::string name, size_t n=std::numeric_limits< std::size_t >::max())
Definition: observer.h:67
Data structure representing JSON format.
Definition: json.h:355
namespace of xgboost
Definition: base.h:110