* Refactor configuration [Part II].
* General changes:
** Remove `Init` methods to avoid ambiguity.
** Remove `Configure(std::map<>)` to avoid redundant copying and prepare for
parameter validation. (`std::vector` is returned from `InitAllowUnknown`).
** Add name to tree updaters for easier debugging.
* Learner changes:
** Make `LearnerImpl` the only source of configuration.
All configurations are stored and carried out by `LearnerImpl::Configure()`.
** Remove booster in C API.
Originally kept for "compatibility reason", but did not state why. So here
we just remove it.
** Add a `metric_names_` field in `LearnerImpl`.
** Remove `LazyInit`. Configuration will always be lazy.
** Run `Configure` before every iteration.
* Predictor changes:
** Allocate both cpu and gpu predictor.
** Remove cpu_predictor from gpu_predictor.
`GBTree` is now used to dispatch the predictor.
** Remove some GPU Predictor tests.
* IO
No IO changes. The binary model format stability is tested by comparing
hashing value of save models between two commits
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
/*!
|
|
* Copyright 2015 by Contributors
|
|
* \file objective.cc
|
|
* \brief Registry of all objective functions.
|
|
*/
|
|
#include <xgboost/objective.h>
|
|
#include <dmlc/registry.h>
|
|
|
|
#include "../common/host_device_vector.h"
|
|
|
|
namespace dmlc {
|
|
DMLC_REGISTRY_ENABLE(::xgboost::ObjFunctionReg);
|
|
} // namespace dmlc
|
|
|
|
namespace xgboost {
|
|
// implement factory functions
|
|
ObjFunction* ObjFunction::Create(const std::string& name, GenericParameter const* tparam) {
|
|
auto *e = ::dmlc::Registry< ::xgboost::ObjFunctionReg>::Get()->Find(name);
|
|
if (e == nullptr) {
|
|
for (const auto& entry : ::dmlc::Registry< ::xgboost::ObjFunctionReg>::List()) {
|
|
LOG(INFO) << "Objective candidate: " << entry->name;
|
|
}
|
|
LOG(FATAL) << "Unknown objective function " << name;
|
|
}
|
|
auto pobj = (e->body)();
|
|
pobj->tparam_ = tparam;
|
|
return pobj;
|
|
}
|
|
|
|
} // namespace xgboost
|
|
|
|
namespace xgboost {
|
|
namespace obj {
|
|
// List of files that will be force linked in static links.
|
|
#ifdef XGBOOST_USE_CUDA
|
|
DMLC_REGISTRY_LINK_TAG(regression_obj_gpu);
|
|
DMLC_REGISTRY_LINK_TAG(hinge_obj_gpu);
|
|
DMLC_REGISTRY_LINK_TAG(multiclass_obj_gpu);
|
|
#else
|
|
DMLC_REGISTRY_LINK_TAG(regression_obj);
|
|
DMLC_REGISTRY_LINK_TAG(hinge_obj);
|
|
DMLC_REGISTRY_LINK_TAG(multiclass_obj);
|
|
#endif // XGBOOST_USE_CUDA
|
|
DMLC_REGISTRY_LINK_TAG(rank_obj);
|
|
} // namespace obj
|
|
} // namespace xgboost
|