[mlpack-git] master: Refactoring and code cleanup. (2f80ff1)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Mon Feb 9 13:12:34 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/38ccfcc3c3f7dc34cc4ebb449d4cda7e8bd6e44b...ab9bc6b3bb911c155d706cb11d505e4cace31915
>---------------------------------------------------------------
commit 2f80ff1114543eea47a087284126e120decc1ea3
Author: Ryan Curtin <ryan at ratml.org>
Date: Mon Feb 9 11:59:58 2015 -0500
Refactoring and code cleanup.
>---------------------------------------------------------------
2f80ff1114543eea47a087284126e120decc1ea3
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