Implement slope for Pseduo-Huber. (#7727)

* Add objective and metric.
* Some refactoring for CPU/GPU dispatching using linalg module.
This commit is contained in:
Jiaming Yuan
2022-03-14 21:42:38 +08:00
committed by GitHub
parent 4dafb5fac8
commit 98d6faefd6
28 changed files with 456 additions and 290 deletions

View File

@@ -23,7 +23,11 @@ namespace common {
* \return the transformed value.
*/
XGBOOST_DEVICE inline float Sigmoid(float x) {
return 1.0f / (1.0f + expf(-x));
float constexpr kEps = 1e-16; // avoid 0 div
x = std::min(-x, 88.7f); // avoid exp overflow
auto denom = expf(x) + 1.0f + kEps;
auto y = 1.0f / denom;
return y;
}
template <typename T>