MLPACK  1.0.10
incomplete_incremental_termination.hpp
Go to the documentation of this file.
1 
20 #ifndef _INCOMPLETE_INCREMENTAL_TERMINATION_HPP_INCLUDED
21 #define _INCOMPLETE_INCREMENTAL_TERMINATION_HPP_INCLUDED
22 
23 #include <mlpack/core.hpp>
24 
25 namespace mlpack {
26 namespace amf {
27 
28 template <class TerminationPolicy>
30 {
31  public:
32  IncompleteIncrementalTermination(TerminationPolicy t_policy = TerminationPolicy())
33  : t_policy(t_policy) {}
34 
35  template <class MatType>
36  void Initialize(const MatType& V)
37  {
38  t_policy.Initialize(V);
39 
40  incrementalIndex = V.n_rows;
41  iteration = 0;
42  }
43 
44  bool IsConverged(arma::mat& W, arma::mat& H)
45  {
46  iteration++;
47  if(iteration % incrementalIndex == 0)
48  return t_policy.IsConverged(W, H);
49  else return false;
50  }
51 
52  const double& Index()
53  {
54  return t_policy.Index();
55  }
56  const size_t& Iteration()
57  {
58  return iteration;
59  }
60  const size_t& MaxIterations()
61  {
62  return t_policy.MaxIterations();
63  }
64 
65  private:
66  TerminationPolicy t_policy;
67 
69  size_t iteration;
70 };
71 
72 }; // namespace amf
73 }; // namespace mlpack
74 
75 #endif
76 
IncompleteIncrementalTermination(TerminationPolicy t_policy=TerminationPolicy())