GPU implementation of AFT survival objective and metric (#5714)
* Add interval accuracy * De-virtualize AFT functions * Lint * Refactor AFT metric using GPU-CPU reducer * Fix R build * Fix build on Windows * Fix copyright header * Clang-tidy * Fix crashing demo * Fix typos in comment; explain GPU ID * Remove unnecessary #include * Add C++ test for interval accuracy * Fix a bug in accuracy metric: use log pred * Refactor AFT objective using GPU-CPU Transform * Lint * Fix lint * Use Ninja to speed up build * Use time, not /usr/bin/time * Add cpu_build worker class, with concurrency = 1 * Use concurrency = 1 only for CUDA build * concurrency = 1 for clang-tidy * Address reviewer's feedback * Update link to AFT paper
This commit is contained in:
committed by
GitHub
parent
7c2686146e
commit
71b0528a2f
@@ -8,36 +8,37 @@
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
|
||||
inline static void RobustTestSuite(ProbabilityDistributionType dist_type,
|
||||
double y_lower, double y_upper, double sigma) {
|
||||
AFTLoss loss(dist_type);
|
||||
template <typename Distribution>
|
||||
inline static void RobustTestSuite(double y_lower, double y_upper, double sigma) {
|
||||
for (int i = 50; i >= -50; --i) {
|
||||
const double y_pred = std::pow(10.0, static_cast<double>(i));
|
||||
const double z = (std::log(y_lower) - std::log(y_pred)) / sigma;
|
||||
const double gradient = loss.Gradient(y_lower, y_upper, std::log(y_pred), sigma);
|
||||
const double hessian = loss.Hessian(y_lower, y_upper, std::log(y_pred), sigma);
|
||||
const double gradient
|
||||
= AFTLoss<Distribution>::Gradient(y_lower, y_upper, std::log(y_pred), sigma);
|
||||
const double hessian
|
||||
= AFTLoss<Distribution>::Hessian(y_lower, y_upper, std::log(y_pred), sigma);
|
||||
ASSERT_FALSE(std::isnan(gradient)) << "z = " << z << ", y \\in ["
|
||||
<< y_lower << ", " << y_upper << "], y_pred = " << y_pred
|
||||
<< ", dist = " << static_cast<int>(dist_type);
|
||||
<< ", dist = " << static_cast<int>(Distribution::Type());
|
||||
ASSERT_FALSE(std::isinf(gradient)) << "z = " << z << ", y \\in ["
|
||||
<< y_lower << ", " << y_upper << "], y_pred = " << y_pred
|
||||
<< ", dist = " << static_cast<int>(dist_type);
|
||||
<< ", dist = " << static_cast<int>(Distribution::Type());
|
||||
ASSERT_FALSE(std::isnan(hessian)) << "z = " << z << ", y \\in ["
|
||||
<< y_lower << ", " << y_upper << "], y_pred = " << y_pred
|
||||
<< ", dist = " << static_cast<int>(dist_type);
|
||||
<< ", dist = " << static_cast<int>(Distribution::Type());
|
||||
ASSERT_FALSE(std::isinf(hessian)) << "z = " << z << ", y \\in ["
|
||||
<< y_lower << ", " << y_upper << "], y_pred = " << y_pred
|
||||
<< ", dist = " << static_cast<int>(dist_type);
|
||||
<< ", dist = " << static_cast<int>(Distribution::Type());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AFTLoss, RobustGradientPair) { // Ensure that INF and NAN don't show up in gradient pair
|
||||
RobustTestSuite(ProbabilityDistributionType::kNormal, 16.0, 200.0, 2.0);
|
||||
RobustTestSuite(ProbabilityDistributionType::kLogistic, 16.0, 200.0, 2.0);
|
||||
RobustTestSuite(ProbabilityDistributionType::kExtreme, 16.0, 200.0, 2.0);
|
||||
RobustTestSuite(ProbabilityDistributionType::kNormal, 100.0, 100.0, 2.0);
|
||||
RobustTestSuite(ProbabilityDistributionType::kLogistic, 100.0, 100.0, 2.0);
|
||||
RobustTestSuite(ProbabilityDistributionType::kExtreme, 100.0, 100.0, 2.0);
|
||||
RobustTestSuite<NormalDistribution>(16.0, 200.0, 2.0);
|
||||
RobustTestSuite<LogisticDistribution>(16.0, 200.0, 2.0);
|
||||
RobustTestSuite<ExtremeDistribution>(16.0, 200.0, 2.0);
|
||||
RobustTestSuite<NormalDistribution>(100.0, 100.0, 2.0);
|
||||
RobustTestSuite<LogisticDistribution>(100.0, 100.0, 2.0);
|
||||
RobustTestSuite<ExtremeDistribution>(100.0, 100.0, 2.0);
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
|
||||
Reference in New Issue
Block a user