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));
102 residue = sum / count;
103 residue = sqrt(residue);
107 Log::Info <<
"Iteration " << iteration <<
"; residue "
108 << ((residueOld - residue) / residueOld) <<
".\n";
111 if ((residueOld - residue) / residueOld < tolerance && iteration > 4)
114 if (reverseStepCount == 0 && isCopy ==
false)
122 c_indexOld = residueOld;
131 reverseStepCount = 0;
133 if (residue <= c_indexOld && isCopy ==
true)
140 if (reverseStepCount == reverseStepTolerance || iteration > maxIterations)
156 const double&
Index()
const {
return residue; }
173 size_t maxIterations;
186 size_t reverseStepTolerance;
188 size_t reverseStepCount;
204 #endif // _MLPACK_METHODS_AMF_SIMPLE_TOLERANCE_TERMINATION_HPP_INCLUDED