From 8aa274d2964a199f9cf81fe6e5d205c03549ff9c Mon Sep 17 00:00:00 2001 From: "Brian C. Van Essen" Date: Tue, 25 Jun 2024 11:43:36 -0700 Subject: [PATCH] Increasing the precision of the reported error for check metric. --- src/callbacks/check_metric.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/callbacks/check_metric.cpp b/src/callbacks/check_metric.cpp index 611e2b16bfc..b3e8f8f79cd 100644 --- a/src/callbacks/check_metric.cpp +++ b/src/callbacks/check_metric.cpp @@ -37,6 +37,7 @@ #include "lbann/proto/callbacks.pb.h" +#include #include #include #include @@ -59,11 +60,19 @@ check_metric::check_metric(std::string metric_name, if (lower_bound > upper_bound) { std::stringstream err; err << "callback \"" << name() << "\" " - << "got an invalid range for metric values " + << "got an invalid range for metric values " << std::setprecision(9) << "(lower bound " << m_lower_bound << ", " << "upper bound " << m_upper_bound << ")"; LBANN_ERROR(err.str()); } + if (lower_bound == upper_bound) { + std::stringstream err; + err << "callback \"" << name() << "\" " + << "got an zero range for metric values " << std::setprecision(9) + << "(lower bound " << m_lower_bound << " == " + << "upper bound " << m_upper_bound << ")"; + LBANN_WARNING(err.str()); + } } check_metric::check_metric() : check_metric("", {}, 0, 0, false) {} @@ -122,8 +131,8 @@ void check_metric::do_check_metric(const model& m) const if (!(m_lower_bound <= value && value <= m_upper_bound)) { err << "callback \"" << name() << "\" expected " << "metric \"" << m_metric_name << "\" " - << "to have a value in range " - << "[" << m_lower_bound << "," << m_upper_bound << "], " + << "to have a value in range " << std::setprecision(9) << "[" + << m_lower_bound << "," << m_upper_bound << "], " << "but found a value of " << value; if (m_error_on_failure) { LBANN_ERROR(err.str());