xgboost
linear_updater.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 by Contributors
3  */
4 #pragma once
5 
6 #include <dmlc/registry.h>
7 #include <xgboost/base.h>
8 #include <xgboost/data.h>
9 #include <functional>
10 #include <string>
11 #include <utility>
12 #include <vector>
13 #include "../../src/gbm/gblinear_model.h"
14 #include "../../src/common/host_device_vector.h"
15 
16 namespace xgboost {
21  public:
23  virtual ~LinearUpdater() = default;
28  virtual void Init(
29  const std::vector<std::pair<std::string, std::string> >& args) = 0;
30 
40  virtual void Update(HostDeviceVector<GradientPair>* in_gpair, DMatrix* data,
41  gbm::GBLinearModel* model,
42  double sum_instance_weight) = 0;
43 
48  static LinearUpdater* Create(const std::string& name);
49 };
50 
55  : public dmlc::FunctionRegEntryBase<LinearUpdaterReg,
56  std::function<LinearUpdater*()> > {};
57 
61 #define XGBOOST_REGISTER_LINEAR_UPDATER(UniqueId, Name) \
62  static DMLC_ATTRIBUTE_UNUSED ::xgboost::LinearUpdaterReg& \
63  __make_##LinearUpdaterReg##_##UniqueId##__ = \
64  ::dmlc::Registry< ::xgboost::LinearUpdaterReg>::Get()->__REGISTER__( \
65  Name)
66 
67 } // namespace xgboost
virtual void Init(const std::vector< std::pair< std::string, std::string > > &args)=0
Initialize the updater with given arguments.
virtual ~LinearUpdater()=default
virtual destructor
Definition: host_device_vector.h:200
The input data structure of xgboost.
virtual void Update(HostDeviceVector< GradientPair > *in_gpair, DMatrix *data, gbm::GBLinearModel *model, double sum_instance_weight)=0
Updates linear model given gradients.
Internal data structured used by XGBoost during training. There are two ways to create a customized D...
Definition: data.h:406
interface of linear updater
Definition: linear_updater.h:20
Registry entry for linear updater.
Definition: linear_updater.h:54
static LinearUpdater * Create(const std::string &name)
Create a linear updater given name.
namespace of xgboost
Definition: base.h:79
defines configuration macros of xgboost.