merge_init.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_AMF_MERGE_INIT_HPP
15 #define MLPACK_METHODS_AMF_MERGE_INIT_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace amf {
21 
26 template<typename WInitializationRuleType, typename HInitializationRuleType>
28 {
29  public:
30  // Empty constructor required for the InitializeRule template
32 
33  // Initialize the MergeInitialization object with existing initialization
34  // rules.
35  MergeInitialization(const WInitializationRuleType& wInitRule,
36  const HInitializationRuleType& hInitRule) :
37  wInitializationRule(wInitRule),
38  hInitializationRule(hInitRule)
39  { }
40 
49  template<typename MatType>
50  inline void Initialize(const MatType& V,
51  const size_t r,
52  arma::mat& W,
53  arma::mat& H)
54  {
55  wInitializationRule.InitializeOne(V, r, W);
56  hInitializationRule.InitializeOne(V, r, H, false);
57  }
58 
59  private:
60  // Initialization rule for W matrix
61  WInitializationRuleType wInitializationRule;
62  // Initialization rule for H matrix
63  HInitializationRuleType hInitializationRule;
64 };
65 
66 } // namespace amf
67 } // namespace mlpack
68 
69 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
This initialization rule for AMF simply takes in two initialization rules, and initialize W with the ...
Definition: merge_init.hpp:27
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Initialize(const MatType &V, const size_t r, arma::mat &W, arma::mat &H)
Initialize W and H with the corresponding initialization rules.
Definition: merge_init.hpp:50
MergeInitialization(const WInitializationRuleType &wInitRule, const HInitializationRuleType &hInitRule)
Definition: merge_init.hpp:35