[mlpack-git] master: Code cleanup. (58d48bb)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:16:04 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit 58d48bb0ba7929768234147e260f70f4eea0e03f
Author: Ryan Curtin <ryan at ratml.org>
Date: Mon Feb 9 13:17:40 2015 -0500
Code cleanup.
>---------------------------------------------------------------
58d48bb0ba7929768234147e260f70f4eea0e03f
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