From 2231940d1d08f5aca23cf53d922642996a098d44 Mon Sep 17 00:00:00 2001 From: Gorkem Ozkaya Date: Mon, 21 Dec 2020 11:11:40 -0800 Subject: [PATCH] Clip small positive values in gamma-nloglik (#6537) For the `gamma-nloglik` eval metric, small positive values in the labels are causing `NaN`'s in the outputs, as reported here: https://github.com/dmlc/xgboost/issues/5349. This will add clipping on them, similar to what is done in other metrics like `poisson-nloglik` and `logloss`. --- src/metric/elementwise_metric.cu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/metric/elementwise_metric.cu b/src/metric/elementwise_metric.cu index e1e3de6cdf91..7e4e47444ef7 100644 --- a/src/metric/elementwise_metric.cu +++ b/src/metric/elementwise_metric.cu @@ -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;