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