[mlpack-git] master: Add Index(), and make convergence occur for all iterations after the maximum iteration. (da092bd)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Tue Jul 7 12:04:56 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/9e806819495ee24c60d7b63b1fee1ab74c52f6cc...da092bd34072dae51aeca3df868430f34c4cccb5

>---------------------------------------------------------------

commit da092bd34072dae51aeca3df868430f34c4cccb5
Author: Ryan Curtin <ryan at ratml.org>
Date:   Tue Jul 7 16:04:19 2015 +0000

    Add Index(), and make convergence occur for all iterations after the maximum iteration.


>---------------------------------------------------------------

da092bd34072dae51aeca3df868430f34c4cccb5
 .../amf/termination_policies/max_iteration_termination.hpp       | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/methods/amf/termination_policies/max_iteration_termination.hpp b/src/mlpack/methods/amf/termination_policies/max_iteration_termination.hpp
index ac1cc7b..69e30c0 100644
--- a/src/mlpack/methods/amf/termination_policies/max_iteration_termination.hpp
+++ b/src/mlpack/methods/amf/termination_policies/max_iteration_termination.hpp
@@ -47,7 +47,14 @@ class MaxIterationTermination
   bool IsConverged(const arma::mat& /* H */, const arma::mat& /* W */)
   {
     // Return true if we have performed the correct number of iterations.
-    return (++iteration == maxIterations);
+    return (++iteration >= maxIterations);
+  }
+
+  //! Return something similar to the residue, which in this case is just the
+  //! number of iterations left, since we don't have access to anything else.
+  size_t Index()
+  {
+    return (iteration > maxIterations) ? 0 : maxIterations - iteration;
   }
 
   //! Get the current iteration.



More information about the mlpack-git mailing list