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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user