Use `UpdateAllowUnknown' for non-model related parameter. (#4961)
* Use `UpdateAllowUnknown' for non-model related parameter. Model parameter can not pack an additional boolean value due to binary IO format. This commit deals only with non-model related parameter configuration. * Add tidy command line arg for use-dmlc-gtest.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
/*!
|
||||
* Copyright 2017-2019 XGBoost contributors
|
||||
*/
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
#ifndef XGBOOST_TREE_PARAM_H_
|
||||
#define XGBOOST_TREE_PARAM_H_
|
||||
|
||||
#include <dmlc/parameter.h>
|
||||
#include <xgboost/data.h>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "xgboost/parameter.h"
|
||||
#include "xgboost/data.h"
|
||||
|
||||
namespace xgboost {
|
||||
namespace tree {
|
||||
|
||||
/*! \brief training parameters for regression tree */
|
||||
struct TrainParam : public dmlc::Parameter<TrainParam> {
|
||||
struct TrainParam : public XGBoostParameter<TrainParam> {
|
||||
// learning step size for a time
|
||||
float learning_rate;
|
||||
// minimum loss change required for a split
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
#include <dmlc/json.h>
|
||||
#include <dmlc/registry.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
@@ -15,7 +16,8 @@
|
||||
#include <utility>
|
||||
|
||||
#include "xgboost/logging.h"
|
||||
#include "xgboost/host_device_vector.h"
|
||||
#include "xgboost/parameter.h"
|
||||
|
||||
#include "param.h"
|
||||
#include "split_evaluator.h"
|
||||
#include "../common/common.h"
|
||||
@@ -67,7 +69,7 @@ bool SplitEvaluator::CheckFeatureConstraint(bst_uint nodeid, bst_uint featureid)
|
||||
}
|
||||
|
||||
//! \brief Encapsulates the parameters for ElasticNet
|
||||
struct ElasticNetParams : public dmlc::Parameter<ElasticNetParams> {
|
||||
struct ElasticNetParams : public XGBoostParameter<ElasticNetParams> {
|
||||
bst_float reg_lambda;
|
||||
bst_float reg_alpha;
|
||||
// maximum delta update we can add in weight estimation
|
||||
@@ -105,7 +107,7 @@ class ElasticNet final : public SplitEvaluator {
|
||||
}
|
||||
}
|
||||
void Init(const Args& args) override {
|
||||
params_.InitAllowUnknown(args);
|
||||
params_.UpdateAllowUnknown(args);
|
||||
}
|
||||
|
||||
SplitEvaluator* GetHostClone() const override {
|
||||
@@ -185,7 +187,7 @@ XGBOOST_REGISTER_SPLIT_EVALUATOR(ElasticNet, "elastic_net")
|
||||
split evaluator
|
||||
*/
|
||||
struct MonotonicConstraintParams
|
||||
: public dmlc::Parameter<MonotonicConstraintParams> {
|
||||
: public XGBoostParameter<MonotonicConstraintParams> {
|
||||
std::vector<bst_int> monotone_constraints;
|
||||
|
||||
DMLC_DECLARE_PARAMETER(MonotonicConstraintParams) {
|
||||
@@ -212,7 +214,7 @@ class MonotonicConstraint final : public SplitEvaluator {
|
||||
void Init(const Args& args)
|
||||
override {
|
||||
inner_->Init(args);
|
||||
params_.InitAllowUnknown(args);
|
||||
params_.UpdateAllowUnknown(args);
|
||||
Reset();
|
||||
}
|
||||
|
||||
@@ -337,7 +339,7 @@ XGBOOST_REGISTER_SPLIT_EVALUATOR(MonotonicConstraint, "monotonic")
|
||||
split evaluator
|
||||
*/
|
||||
struct InteractionConstraintParams
|
||||
: public dmlc::Parameter<InteractionConstraintParams> {
|
||||
: public XGBoostParameter<InteractionConstraintParams> {
|
||||
std::string interaction_constraints;
|
||||
bst_uint num_feature;
|
||||
|
||||
@@ -371,7 +373,7 @@ class InteractionConstraint final : public SplitEvaluator {
|
||||
void Init(const Args& args)
|
||||
override {
|
||||
inner_->Init(args);
|
||||
params_.InitAllowUnknown(args);
|
||||
params_.UpdateAllowUnknown(args);
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ XGBOOST_REGISTER_TREE_IO(JsonGenerator, "json")
|
||||
return new JsonGenerator(fmap, attrs, with_stats);
|
||||
});
|
||||
|
||||
struct GraphvizParam : public dmlc::Parameter<GraphvizParam> {
|
||||
struct GraphvizParam : public XGBoostParameter<GraphvizParam> {
|
||||
std::string yes_color;
|
||||
std::string no_color;
|
||||
std::string rankdir;
|
||||
@@ -462,7 +462,7 @@ class GraphvizGenerator : public TreeGenerator {
|
||||
public:
|
||||
GraphvizGenerator(FeatureMap const& fmap, std::string const& attrs, bool with_stats) :
|
||||
TreeGenerator(fmap, with_stats) {
|
||||
param_.InitAllowUnknown(std::map<std::string, std::string>{});
|
||||
param_.UpdateAllowUnknown(std::map<std::string, std::string>{});
|
||||
using KwArg = std::map<std::string, std::map<std::string, std::string>>;
|
||||
KwArg kwargs;
|
||||
if (attrs.length() != 0) {
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace tree {
|
||||
class BaseMaker: public TreeUpdater {
|
||||
public:
|
||||
void Configure(const Args& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
param_.UpdateAllowUnknown(args);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -26,7 +26,7 @@ DMLC_REGISTRY_FILE_TAG(updater_colmaker);
|
||||
class ColMaker: public TreeUpdater {
|
||||
public:
|
||||
void Configure(const Args& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
param_.UpdateAllowUnknown(args);
|
||||
spliteval_.reset(SplitEvaluator::Create(param_.split_evaluator));
|
||||
spliteval_->Init(args);
|
||||
}
|
||||
@@ -773,7 +773,7 @@ class ColMaker: public TreeUpdater {
|
||||
class DistColMaker : public ColMaker {
|
||||
public:
|
||||
void Configure(const Args& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
param_.UpdateAllowUnknown(args);
|
||||
pruner_.reset(TreeUpdater::Create("prune", tparam_));
|
||||
pruner_->Configure(args);
|
||||
spliteval_.reset(SplitEvaluator::Create(param_.split_evaluator));
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "xgboost/host_device_vector.h"
|
||||
#include "xgboost/parameter.h"
|
||||
#include "xgboost/span.h"
|
||||
|
||||
#include "../common/common.h"
|
||||
@@ -38,7 +39,7 @@ DMLC_REGISTRY_FILE_TAG(updater_gpu_hist);
|
||||
|
||||
// training parameters specific to this algorithm
|
||||
struct GPUHistMakerTrainParam
|
||||
: public dmlc::Parameter<GPUHistMakerTrainParam> {
|
||||
: public XGBoostParameter<GPUHistMakerTrainParam> {
|
||||
bool single_precision_histogram;
|
||||
// number of rows in a single GPU batch
|
||||
int gpu_batch_nrows;
|
||||
@@ -969,9 +970,9 @@ class GPUHistMakerSpecialised {
|
||||
public:
|
||||
GPUHistMakerSpecialised() : initialised_{false}, p_last_fmat_{nullptr} {}
|
||||
void Configure(const Args& args, GenericParameter const* generic_param) {
|
||||
param_.InitAllowUnknown(args);
|
||||
param_.UpdateAllowUnknown(args);
|
||||
generic_param_ = generic_param;
|
||||
hist_maker_param_.InitAllowUnknown(args);
|
||||
hist_maker_param_.UpdateAllowUnknown(args);
|
||||
device_ = generic_param_->gpu_id;
|
||||
CHECK_GE(device_, 0) << "Must have at least one device";
|
||||
|
||||
@@ -1107,7 +1108,7 @@ class GPUHistMakerSpecialised {
|
||||
class GPUHistMaker : public TreeUpdater {
|
||||
public:
|
||||
void Configure(const Args& args) override {
|
||||
hist_maker_param_.InitAllowUnknown(args);
|
||||
hist_maker_param_.UpdateAllowUnknown(args);
|
||||
float_maker_.reset();
|
||||
double_maker_.reset();
|
||||
if (hist_maker_param_.single_precision_histogram) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class TreePruner: public TreeUpdater {
|
||||
|
||||
// set training parameter
|
||||
void Configure(const Args& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
param_.UpdateAllowUnknown(args);
|
||||
syncher_->Configure(args);
|
||||
}
|
||||
// update the tree, do pruning
|
||||
|
||||
@@ -38,7 +38,7 @@ void QuantileHistMaker::Configure(const Args& args) {
|
||||
pruner_.reset(TreeUpdater::Create("prune", tparam_));
|
||||
}
|
||||
pruner_->Configure(args);
|
||||
param_.InitAllowUnknown(args);
|
||||
param_.UpdateAllowUnknown(args);
|
||||
is_gmat_initialized_ = false;
|
||||
|
||||
// initialize the split evaluator
|
||||
|
||||
@@ -22,7 +22,7 @@ DMLC_REGISTRY_FILE_TAG(updater_refresh);
|
||||
class TreeRefresher: public TreeUpdater {
|
||||
public:
|
||||
void Configure(const Args& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
param_.UpdateAllowUnknown(args);
|
||||
}
|
||||
char const* Name() const override {
|
||||
return "refresh";
|
||||
|
||||
Reference in New Issue
Block a user