MLPACK  1.0.11
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:
37  IncompleteIncrementalTermination(TerminationPolicy t_policy = TerminationPolicy())
38  : t_policy(t_policy) {}
39 
40  template <class MatType>
41  void Initialize(const MatType& V)
42  {
43  t_policy.Initialize(V);
44 
45  incrementalIndex = V.n_rows;
46  iteration = 0;
47  }
48 
49  bool IsConverged(arma::mat& W, arma::mat& H)
50  {
51  iteration++;
52  if(iteration % incrementalIndex == 0)
53  return t_policy.IsConverged(W, H);
54  else return false;
55  }
56 
57  const double& Index()
58  {
59  return t_policy.Index();
60  }
61  const size_t& Iteration()
62  {
63  return iteration;
64  }
65  const size_t& MaxIterations()
66  {
67  return t_policy.MaxIterations();
68  }
69 
70  private:
71  TerminationPolicy t_policy;
72 
74  size_t iteration;
75 };
76 
77 }; // namespace amf
78 }; // namespace mlpack
79 
80 #endif
81 
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:31
IncompleteIncrementalTermination(TerminationPolicy t_policy=TerminationPolicy())
Empty constructor.