Skip to content

Commit

Permalink
Clip small positive values in gamma-nloglik
Browse files Browse the repository at this point in the history
For the `gamma-nloglik` eval metric, small positive values in the labels are causing `NaN`'s in the outputs, as reported here: #5349. This will add clipping on them, similar to what is done in other metrics like `poisson-nloglik` and `logloss`.
  • Loading branch information
gorkemozkaya authored Dec 21, 2020
1 parent fbb980d commit 0ed3370
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/metric/elementwise_metric.cu
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ struct EvalGammaNLogLik {
}

XGBOOST_DEVICE bst_float EvalRow(bst_float y, bst_float py) const {
const bst_float eps = 1e-16f;
if (y < eps) y = eps;
bst_float psi = 1.0;
bst_float theta = -1. / py;
bst_float a = psi;
Expand Down

0 comments on commit 0ed3370

Please sign in to comment.