[mlpack-git] master: Refactoring and code cleanup. (59d721b)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:16:00 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit 59d721ba131a7543f0cebcf8b164a716e85850dd
Author: Ryan Curtin <ryan at ratml.org>
Date: Mon Feb 9 11:59:58 2015 -0500
Refactoring and code cleanup.
>---------------------------------------------------------------
59d721ba131a7543f0cebcf8b164a716e85850dd
src/mlpack/methods/amf/init_rules/random_init.hpp | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/mlpack/methods/amf/init_rules/random_init.hpp b/src/mlpack/methods/amf/init_rules/random_init.hpp
index 8a17ba3..eceb0f3 100644
--- a/src/mlpack/methods/amf/init_rules/random_init.hpp
+++ b/src/mlpack/methods/amf/init_rules/random_init.hpp
@@ -2,7 +2,7 @@
* @file random_init.hpp
* @author Mohan Rajendran
*
- * Intialization rule for Non-Negative Matrix Factorization (NMF). This simple
+ * Intialization rule for alternating matrix forization (AMF). This simple
* initialization is performed by assigning a random matrix to W and H.
*/
#ifndef __MLPACK_METHODS_LMF_RANDOM_INIT_HPP
@@ -13,12 +13,24 @@
namespace mlpack {
namespace amf {
+/**
+ * This initialization rule for AMF simply fills the W and H matrices with
+ * uniform random noise in [0, 1].
+ */
class RandomInitialization
{
public:
// Empty constructor required for the InitializeRule template
RandomInitialization() { }
+ /**
+ * Fill W and H with random uniform noise.
+ *
+ * @param V Input matrix.
+ * @param r Rank of decomposition.
+ * @param W W matrix, to be filled with random noise.
+ * @param H H matrix, to be filled with random noise.
+ */
template<typename MatType>
inline static void Initialize(const MatType& V,
const size_t r,
@@ -26,8 +38,8 @@ class RandomInitialization
arma::mat& H)
{
// Simple implementation (left in the header file due to its simplicity).
- size_t n = V.n_rows;
- size_t m = V.n_cols;
+ const size_t n = V.n_rows;
+ const size_t m = V.n_cols;
// Intialize to random values.
W.randu(n, r);
More information about the mlpack-git
mailing list