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:
Rory Mitchell
2018-05-09 20:25:51 +12:00
committed by GitHub
parent b8a0d66fe6
commit 088bb4b27c
3 changed files with 4 additions and 3 deletions

View File

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

View File

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