diff --git a/src/mlpack/methods/amf/amf_impl.hpp b/src/mlpack/methods/amf/amf_impl.hpp index 2bd0ee9753..9ee69a4b99 100644 --- a/src/mlpack/methods/amf/amf_impl.hpp +++ b/src/mlpack/methods/amf/amf_impl.hpp @@ -63,7 +63,7 @@ double AMF::Apply( update.Initialize(V, r); - while (((oldResidue - residue) / oldResidue >= tolerance || iteration < 4) && iteration != maxIterations) + while ((std::abs(oldResidue - residue) / oldResidue >= tolerance || iteration < 4) && iteration != maxIterations) { // Update step. // Update the value of W and H based on the Update Rules provided