From d559ce3d837cc1afff0a5f902c8cef28914ee63a Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Mon, 23 Jun 2014 21:38:42 +0000 Subject: [PATCH] Fix for convergence, because sometimes the residue may increase (especially with ALS update rules). --- src/mlpack/methods/amf/amf_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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