Prevent multiclass Hessian approaching 0 (#3304)
* Prevent Hessian in multiclass objective becoming zero * Set default learning rate to 0.5 for "coord_descent" linear updater
This commit is contained in:
parent
b8a0d66fe6
commit
088bb4b27c
@ -27,7 +27,7 @@ struct CoordinateTrainParam : public dmlc::Parameter<CoordinateTrainParam> {
|
||||
DMLC_DECLARE_PARAMETER(CoordinateTrainParam) {
|
||||
DMLC_DECLARE_FIELD(learning_rate)
|
||||
.set_lower_bound(0.0f)
|
||||
.set_default(1.0f)
|
||||
.set_default(0.5f)
|
||||
.describe("Learning rate of each update.");
|
||||
DMLC_DECLARE_FIELD(reg_lambda)
|
||||
.set_lower_bound(0.0f)
|
||||
|
||||
@ -65,7 +65,8 @@ class SoftmaxMultiClassObj : public ObjFunction {
|
||||
const bst_float wt = info.GetWeight(i);
|
||||
for (int k = 0; k < nclass; ++k) {
|
||||
bst_float p = rec[k];
|
||||
const bst_float h = 2.0f * p * (1.0f - p) * wt;
|
||||
const float eps = 1e-16f;
|
||||
const bst_float h = fmax(2.0f * p * (1.0f - p) * wt, eps);
|
||||
if (label == k) {
|
||||
gpair[i * nclass + k] = GradientPair((p - 1.0f) * wt, h);
|
||||
} else {
|
||||
|
||||
@ -31,7 +31,7 @@ TEST(Linear, coordinate) {
|
||||
mat->InitColAccess(enabled, 1.0f, 1 << 16, false);
|
||||
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
||||
xgboost::LinearUpdater::Create("coord_descent"));
|
||||
updater->Init({});
|
||||
updater->Init({{"eta", "1."}});
|
||||
xgboost::HostDeviceVector<xgboost::GradientPair> gpair(
|
||||
mat->Info().num_row_, xgboost::GradientPair(-5, 1.0));
|
||||
xgboost::gbm::GBLinearModel model;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user