12 #ifndef _MLPACK_METHODS_AMF_SIMPLE_TOLERANCE_TERMINATION_HPP_INCLUDED 13 #define _MLPACK_METHODS_AMF_SIMPLE_TOLERANCE_TERMINATION_HPP_INCLUDED 30 template <
class MatType>
36 const size_t maxIterations = 10000,
37 const size_t reverseStepTolerance = 3)
38 : tolerance(tolerance),
39 maxIterations(maxIterations),
40 reverseStepTolerance(reverseStepTolerance) {}
81 for (
size_t i = 0; i < n; i++)
83 for (
size_t j = 0; j < m; j++)
86 if ((temp = (*V)(i, j)) != 0)
88 temp = (temp - WH(i, j));
95 residue = sum / count;
96 residue = sqrt(residue);
100 Log::Info <<
"Iteration " << iteration <<
"; residue " 101 << ((residueOld - residue) / residueOld) <<
".\n";
104 if ((residueOld - residue) / residueOld < tolerance && iteration > 4)
107 if (reverseStepCount == 0 && isCopy ==
false)
115 c_indexOld = residueOld;
124 reverseStepCount = 0;
126 if (residue <= c_indexOld && isCopy ==
true)
133 if (reverseStepCount == reverseStepTolerance || iteration > maxIterations)
149 const double&
Index()
const {
return residue; }
166 size_t maxIterations;
180 size_t reverseStepTolerance;
182 size_t reverseStepCount;
198 #endif // _MLPACK_METHODS_AMF_SIMPLE_TOLERANCE_TERMINATION_HPP_INCLUDED
SimpleToleranceTermination(const double tolerance=1e-5, const size_t maxIterations=10000, const size_t reverseStepTolerance=3)
empty constructor
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Initialize(const MatType &V)
Initializes the termination policy before stating the factorization.
static MLPACK_EXPORT util::PrefixedOutStream Info
Prints informational messages if –verbose is specified, prefixed with [INFO ].
const double & Tolerance() const
Access tolerance value.
bool IsConverged(arma::mat &W, arma::mat &H)
Check if termination criterio is met.
This class implements residue tolerance termination policy.
const size_t & Iteration() const
Get current iteration count.
const double & Index() const
Get current value of residue.
const size_t & MaxIterations() const
Access upper limit of iteration count.