[mlpack-git] master: Code cleanup. (ee69124)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Mon Feb 9 14:09:16 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/ab9bc6b3bb911c155d706cb11d505e4cace31915...8b3dd9b9dfabadaeb7d62151162f20e1bf9fbbe3
>---------------------------------------------------------------
commit ee691246a140264051d1f6a53f71257c21e3dcca
Author: Ryan Curtin <ryan at ratml.org>
Date: Mon Feb 9 13:17:40 2015 -0500
Code cleanup.
>---------------------------------------------------------------
ee691246a140264051d1f6a53f71257c21e3dcca
src/mlpack/methods/amf/update_rules/nmf_als.hpp | 56 +++++++++++++++++--------
1 file changed, 38 insertions(+), 18 deletions(-)
diff --git a/src/mlpack/methods/amf/update_rules/nmf_als.hpp b/src/mlpack/methods/amf/update_rules/nmf_als.hpp
index ea96630..395f93d 100644
--- a/src/mlpack/methods/amf/update_rules/nmf_als.hpp
+++ b/src/mlpack/methods/amf/update_rules/nmf_als.hpp
@@ -14,11 +14,24 @@ namespace amf {
/**
* This class implements a method titled 'Alternating Least Squares' described
- * in the paper 'Positive Matrix Factorization: A Non-negative Factor Model with
- * Optimal Utilization of Error Estimates of Data Values' by P Paatero and
- * U Tapper. It uses least squares projection formula to reduce the error
- * value of \f$ \sqrt{\sum_i \sum_j(V-WH)^2} \f$ by alternately calculating W
- * and H respectively while holding the other matrix constant.
+ * in the following paper:
+ *
+ * @code
+ * @article{paatero1994positive,
+ * title={Positive matrix factorization: A non-negative factor model with
+ * optimal utilization of error estimates of data values},
+ * author={Paatero, P. and Tapper, U.},
+ * journal={Environmetrics},
+ * volume={5},
+ * number={2},
+ * pages={111--126},
+ * year={1994}
+ * }
+ * @endcode
+ *
+ * It uses the least squares projection formula to reduce the error value of
+ * \f$ \sqrt{\sum_i \sum_j(V-WH)^2} \f$ by alternately calculating W and H
+ * respectively while holding the other matrix constant.
*/
class NMFALSUpdate
{
@@ -26,20 +39,25 @@ class NMFALSUpdate
//! Empty constructor required for the UpdateRule template.
NMFALSUpdate() { }
+ /**
+ * Set initial values for the factorization. In this case, we don't need to
+ * set anything.
+ */
template<typename MatType>
- void Initialize(const MatType& dataset, const size_t rank)
+ void Initialize(const MatType& /* dataset */, const size_t /* rank */)
{
- (void)dataset;
- (void)rank;
+ // Nothing to do.
}
/**
- * The update rule for the basis matrix W. The formula used is
+ * The update rule for the basis matrix W. The formula used isa
+ *
* \f[
- * W^T = \frac{HV^T}{HH^T}
+ * W^T = \frac{H V^T}{H H^T}
* \f]
- * The function takes in all the matrices and only changes the
- * value of the W matrix.
+ *
+ * The function takes in all the matrices and only changes the value of the W
+ * matrix.
*
* @param V Input matrix to be factorized.
* @param W Basis matrix to be updated.
@@ -54,7 +72,7 @@ class NMFALSUpdate
// W = (inv(H * H.t()) * H * V.t()).t();
W = V * H.t() * pinv(H * H.t());
- // Set all negative numbers to machine epsilon
+ // Set all negative numbers to machine epsilon.
for (size_t i = 0; i < W.n_elem; i++)
{
if (W(i) < 0.0)
@@ -66,11 +84,13 @@ class NMFALSUpdate
/**
* The update rule for the encoding matrix H. The formula used is
+ *
* \f[
- * H = \frac{W^TV}{W^TW}
+ * H = \frac{W^T V}{W^T W}
* \f]
- * The function takes in all the matrices and only changes the
- * value of the H matrix.
+ *
+ * The function takes in all the matrices and only changes the value of the H
+ * matrix.
*
* @param V Input matrix to be factorized.
* @param W Basis matrix.
@@ -94,7 +114,7 @@ class NMFALSUpdate
}
}; // class NMFALSUpdate
-}; // namespace amf
-}; // namespace mlpack
+} // namespace amf
+} // namespace mlpack
#endif
More information about the mlpack-git
mailing list