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:
Jiaming Yuan
2019-10-23 05:50:12 -04:00
committed by GitHub
parent f24be2efb4
commit ac457c56a2
44 changed files with 189 additions and 112 deletions

View File

@@ -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)

View File

@@ -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 */

View File

@@ -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");
}

View File

@@ -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");
}

View File

@@ -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"