mlpack  1.0.12
incomplete_incremental_termination.hpp
Go to the documentation of this file.
1 
12 #ifndef _INCOMPLETE_INCREMENTAL_TERMINATION_HPP_INCLUDED
13 #define _INCOMPLETE_INCREMENTAL_TERMINATION_HPP_INCLUDED
14 
15 #include <mlpack/core.hpp>
16 
17 namespace mlpack {
18 namespace amf {
19 
20 template <class TerminationPolicy>
22 {
23  public:
29  IncompleteIncrementalTermination(TerminationPolicy t_policy = TerminationPolicy())
30  : t_policy(t_policy) {}
31 
32  template <class MatType>
33  void Initialize(const MatType& V)
34  {
35  t_policy.Initialize(V);
36 
37  incrementalIndex = V.n_rows;
38  iteration = 0;
39  }
40 
41  bool IsConverged(arma::mat& W, arma::mat& H)
42  {
43  iteration++;
44  if(iteration % incrementalIndex == 0)
45  return t_policy.IsConverged(W, H);
46  else return false;
47  }
48 
49  const double& Index()
50  {
51  return t_policy.Index();
52  }
53  const size_t& Iteration()
54  {
55  return iteration;
56  }
57  const size_t& MaxIterations()
58  {
59  return t_policy.MaxIterations();
60  }
61 
62  private:
63  TerminationPolicy t_policy;
64 
66  size_t iteration;
67 };
68 
69 }; // namespace amf
70 }; // namespace mlpack
71 
72 #endif
73 
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
IncompleteIncrementalTermination(TerminationPolicy t_policy=TerminationPolicy())
Empty constructor.