From 09cd0d67f2fdae252a8ab85324e71dbb4dfe0010 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 19 Oct 2015 07:56:54 -0400 Subject: [PATCH] Check isinf() too. --- src/mlpack/core/optimizers/sgd/sgd_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mlpack/core/optimizers/sgd/sgd_impl.hpp b/src/mlpack/core/optimizers/sgd/sgd_impl.hpp index 9b9a6e3111..166c499a72 100644 --- a/src/mlpack/core/optimizers/sgd/sgd_impl.hpp +++ b/src/mlpack/core/optimizers/sgd/sgd_impl.hpp @@ -60,7 +60,7 @@ double SGD::Optimize(arma::mat& iterate) Log::Info << "SGD: iteration " << i << ", objective " << overallObjective << "." << std::endl; - if (std::isnan(overallObjective)) + if (std::isnan(overallObjective) || std::isinf(overallObjective)) { Log::Warn << "SGD: converged to " << overallObjective << "; terminating" << " with failure. Try a smaller step size?" << std::endl;