mlpack  2.0.1
random_init.hpp
Go to the documentation of this file.
1 
15 #ifndef __MLPACK_METHODS_LMF_RANDOM_INIT_HPP
16 #define __MLPACK_METHODS_LMF_RANDOM_INIT_HPP
17 
18 #include <mlpack/core.hpp>
19 
20 namespace mlpack {
21 namespace amf {
22 
28 {
29  public:
30  // Empty constructor required for the InitializeRule template
32 
41  template<typename MatType>
42  inline static void Initialize(const MatType& V,
43  const size_t r,
44  arma::mat& W,
45  arma::mat& H)
46  {
47  // Simple implementation (left in the header file due to its simplicity).
48  const size_t n = V.n_rows;
49  const size_t m = V.n_cols;
50 
51  // Initialize to random values.
52  W.randu(n, r);
53  H.randu(r, m);
54  }
55 
57  template<typename Archive>
58  void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
59 };
60 
61 } // namespace amf
62 } // namespace mlpack
63 
64 #endif
This initialization rule for AMF simply fills the W and H matrices with uniform random noise in [0...
Definition: random_init.hpp:27
Linear algebra utility functions, generally performed on matrices or vectors.
void Serialize(Archive &, const unsigned int)
Serialize the object (in this case, there is nothing to serialize).
Definition: random_init.hpp:58
static void Initialize(const MatType &V, const size_t r, arma::mat &W, arma::mat &H)
Fill W and H with random uniform noise.
Definition: random_init.hpp:42
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...