[mlpack-git] mlpack-1.0.x: Backport r17307. (d23d216)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:07:04 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : mlpack-1.0.x
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit d23d2163f02909a213e7c0b5bb4f263cb90896a3
Author: Ryan Curtin <ryan at ratml.org>
Date: Sun Dec 7 19:28:13 2014 +0000
Backport r17307.
>---------------------------------------------------------------
d23d2163f02909a213e7c0b5bb4f263cb90896a3
.../simple_tolerance_termination.hpp | 38 ++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/mlpack/methods/amf/termination_policies/simple_tolerance_termination.hpp b/src/mlpack/methods/amf/termination_policies/simple_tolerance_termination.hpp
index 4cb823e..83791d7 100644
--- a/src/mlpack/methods/amf/termination_policies/simple_tolerance_termination.hpp
+++ b/src/mlpack/methods/amf/termination_policies/simple_tolerance_termination.hpp
@@ -25,6 +25,16 @@
namespace mlpack {
namespace amf {
+/**
+ * This class implements residue tolerance termination policy. Termination
+ * criterion is met when increase in residue value drops below the given tolerance.
+ * To accomodate spikes certain number of successive residue drops are accepted.
+ * This upper imit on successive drops can be adjusted with reverseStepCount.
+ * Secondary termination criterion terminates algorithm when iteration count
+ * goes above the threshold.
+ *
+ * @see AMF
+ */
template <class MatType>
class SimpleToleranceTermination
{
@@ -42,6 +52,7 @@ class SimpleToleranceTermination
iteration = 1;
residue = DBL_MIN;
reverseStepCount = 0;
+ isCopy = false;
this->V = &V;
@@ -80,11 +91,17 @@ class SimpleToleranceTermination
residue = sum / count;
residue = sqrt(residue);
+<<<<<<< .working
+ iteration++;
+
+=======
iteration++;
- if((residueOld - residue) / residueOld < tolerance && iteration > 4)
+ // if residue tolerance is not satisfied
+>>>>>>> .merge-right.r17287
+ if ((residueOld - residue) / residueOld < tolerance && iteration > 4)
{
- if(reverseStepCount == 0 && isCopy == false)
+ if (reverseStepCount == 0 && isCopy == false)
{
isCopy = true;
this->W = W;
@@ -120,21 +137,38 @@ class SimpleToleranceTermination
const size_t& Iteration() { return iteration; }
const size_t& MaxIterations() { return maxIterations; }
+ //! Get current iteration count
+ const size_t& Iteration() const { return iteration; }
+
+ //! Access upper limit of iteration count
+ const size_t& MaxIterations() const { return maxIterations; }
+ size_t& MaxIterations() { return maxIterations; }
+
+ //! Access tolerance value
+ const double& Tolerance() const { return tolerance; }
+ double& Tolerance() { return tolerance; }
+
private:
+ //! tolerance
double tolerance;
size_t maxIterations;
const MatType* V;
size_t iteration;
+
+ //! residue values
double residueOld;
double residue;
double normOld;
size_t reverseStepTolerance;
+ //! successive residue drops
size_t reverseStepCount;
bool isCopy;
+
+ //! variables to store information of minimum residue poi
arma::mat W;
arma::mat H;
double c_indexOld;
More information about the mlpack-git
mailing list