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:
@@ -10,6 +10,7 @@
|
||||
#include <limits>
|
||||
|
||||
#include "xgboost/data.h"
|
||||
#include "xgboost/parameter.h"
|
||||
#include "./param.h"
|
||||
#include "../gbm/gblinear_model.h"
|
||||
#include "../common/random.h"
|
||||
@@ -17,7 +18,7 @@
|
||||
namespace xgboost {
|
||||
namespace linear {
|
||||
|
||||
struct CoordinateParam : public dmlc::Parameter<CoordinateParam> {
|
||||
struct CoordinateParam : public XGBoostParameter<CoordinateParam> {
|
||||
int top_k;
|
||||
DMLC_DECLARE_PARAMETER(CoordinateParam) {
|
||||
DMLC_DECLARE_FIELD(top_k)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
#ifndef XGBOOST_LINEAR_PARAM_H_
|
||||
#define XGBOOST_LINEAR_PARAM_H_
|
||||
#include <dmlc/parameter.h>
|
||||
#include "xgboost/parameter.h"
|
||||
|
||||
namespace xgboost {
|
||||
namespace linear {
|
||||
@@ -20,7 +20,7 @@ enum FeatureSelectorEnum {
|
||||
kRandom
|
||||
};
|
||||
|
||||
struct LinearTrainParam : public dmlc::Parameter<LinearTrainParam> {
|
||||
struct LinearTrainParam : public XGBoostParameter<LinearTrainParam> {
|
||||
/*! \brief learning_rate */
|
||||
float learning_rate;
|
||||
/*! \brief regularization weight for L2 norm */
|
||||
|
||||
@@ -26,9 +26,9 @@ class CoordinateUpdater : public LinearUpdater {
|
||||
// set training parameter
|
||||
void Configure(Args const& args) override {
|
||||
const std::vector<std::pair<std::string, std::string> > rest {
|
||||
tparam_.InitAllowUnknown(args)
|
||||
tparam_.UpdateAllowUnknown(args)
|
||||
};
|
||||
cparam_.InitAllowUnknown(rest);
|
||||
cparam_.UpdateAllowUnknown(rest);
|
||||
selector_.reset(FeatureSelector::Create(tparam_.feature_selector));
|
||||
monitor_.Init("CoordinateUpdater");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Copyright 2018 by Contributors
|
||||
* Copyright 2018-2019 by Contributors
|
||||
* \author Rory Mitchell
|
||||
*/
|
||||
|
||||
@@ -36,7 +36,7 @@ class GPUCoordinateUpdater : public LinearUpdater { // NOLINT
|
||||
|
||||
// set training parameter
|
||||
void Configure(Args const& args) override {
|
||||
tparam_.InitAllowUnknown(args);
|
||||
tparam_.UpdateAllowUnknown(args);
|
||||
selector_.reset(FeatureSelector::Create(tparam_.feature_selector));
|
||||
monitor_.Init("GPUCoordinateUpdater");
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class ShotgunUpdater : public LinearUpdater {
|
||||
public:
|
||||
// set training parameter
|
||||
void Configure(Args const& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
param_.UpdateAllowUnknown(args);
|
||||
if (param_.feature_selector != kCyclic &&
|
||||
param_.feature_selector != kShuffle) {
|
||||
LOG(FATAL) << "Unsupported feature selector for shotgun updater.\n"
|
||||
|
||||
Reference in New Issue
Block a user