14 #ifndef __MLPACK_METHODS_LMF_UPDATE_RULES_NMF_MULT_DIV_HPP
15 #define __MLPACK_METHODS_LMF_UPDATE_RULES_NMF_MULT_DIV_HPP
40 template<
typename MatType>
41 void Initialize(
const MatType& dataset,
const size_t rank)
60 template<
typename MatType>
61 inline static void WUpdate(
const MatType& V,
70 for (
size_t i = 0; i < W.n_rows; ++i)
72 for (
size_t j = 0; j < W.n_cols; ++j)
78 t2.set_size(H.n_cols);
79 for (
size_t k = 0; k < t2.n_elem; ++k)
81 t2(k) = H(j, k) * V(i, k) / t1(i, k);
84 W(i, j) = W(i, j) * sum(t2) / sum(H.row(j));
102 template<
typename MatType>
112 for (
size_t i = 0; i < H.n_rows; i++)
114 for (
size_t j = 0; j < H.n_cols; j++)
120 t2.set_size(W.n_rows);
121 for (
size_t k = 0; k < t2.n_elem; ++k)
123 t2(k) = W(k, i) * V(k, j) / t1(k, j);
126 H(i,j) = H(i,j) * sum(t2) / sum(W.col(i));
static void WUpdate(const MatType &V, arma::mat &W, const arma::mat &H)
The update rule for the basis matrix W.
Linear algebra utility functions, generally performed on matrices or vectors.
void Initialize(const MatType &dataset, const size_t rank)
NMFMultiplicativeDivergenceUpdate()
static void HUpdate(const MatType &V, const arma::mat &W, arma::mat &H)
The update rule for the encoding matrix H.
This follows a method described in the paper 'Algorithms for Non-negative Matrix Factorization' by D...