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) :
39 maxIterations(maxIterations),
44 reverseStepTolerance(reverseStepTolerance),
88 for (
size_t i = 0; i < n; ++i)
90 for (
size_t j = 0; j < m; ++j)
93 if ((temp = (*V)(i, j)) != 0)
95 temp = (temp - WH(i, j));
106 residue = sqrt(residue);
110 Log::Info <<
"Iteration " << iteration <<
"; residue " 111 << ((residueOld - residue) / residueOld) <<
".\n";
114 if ((residueOld - residue) / residueOld < tolerance && iteration > 4)
117 if (reverseStepCount == 0 && isCopy ==
false)
125 c_indexOld = residueOld;
134 reverseStepCount = 0;
136 if (residue <= c_indexOld && isCopy ==
true)
143 if (reverseStepCount == reverseStepTolerance || iteration > maxIterations)
160 const double&
Index()
const {
return residue; }
177 size_t maxIterations;
190 size_t reverseStepTolerance;
192 size_t reverseStepCount;
208 #endif // _MLPACK_METHODS_AMF_SIMPLE_TOLERANCE_TERMINATION_HPP_INCLUDED Linear algebra utility functions, generally performed on matrices or vectors.
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.