12 #ifndef MLPACK_METHODS_AMF_SVD_INCOMPLETE_INCREMENTAL_LEARNING_HPP
13 #define MLPACK_METHODS_AMF_SVD_INCOMPLETE_INCREMENTAL_LEARNING_HPP
56 : u(u), kw(kw), kh(kh)
69 template<
typename MatType>
85 template<
typename MatType>
91 deltaW.zeros(V.n_rows, W.n_cols);
95 for (
size_t i = 0; i < V.n_rows; ++i)
97 const double val = V(i, currentUserIndex);
100 deltaW.row(i) += (val - arma::dot(W.row(i), H.col(currentUserIndex))) *
101 H.col(currentUserIndex).t();
104 deltaW.row(i) -= kw * W.row(i);
118 template<
typename MatType>
124 deltaH.zeros(H.n_rows);
128 for (
size_t i = 0; i < V.n_rows; ++i)
130 const double val = V(i, currentUserIndex);
133 deltaH += (val - arma::dot(W.row(i), H.col(currentUserIndex))) *
138 deltaH -= kh * H.col(currentUserIndex);
141 H.col(currentUserIndex++) += u * deltaH;
142 currentUserIndex = currentUserIndex % V.n_cols;
154 size_t currentUserIndex;
162 inline void SVDIncompleteIncrementalLearning::
163 WUpdate<arma::sp_mat>(
const arma::sp_mat& V,
167 arma::mat deltaW(V.n_rows, W.n_cols);
169 for(arma::sp_mat::const_iterator it = V.begin_col(currentUserIndex);
170 it != V.end_col(currentUserIndex);it++)
174 deltaW.row(i) += (val - arma::dot(W.row(i), H.col(currentUserIndex))) *
175 arma::trans(H.col(currentUserIndex));
176 if (kw != 0) deltaW.row(i) -= kw * W.row(i);
183 inline void SVDIncompleteIncrementalLearning::
184 HUpdate<arma::sp_mat>(
const arma::sp_mat& V,
188 arma::mat deltaH(H.n_rows, 1);
191 for(arma::sp_mat::const_iterator it = V.begin_col(currentUserIndex);
192 it != V.end_col(currentUserIndex);it++)
196 if ((val = V(i, currentUserIndex)) != 0)
197 deltaH += (val - arma::dot(W.row(i), H.col(currentUserIndex))) *
198 arma::trans(W.row(i));
200 if (kh != 0) deltaH -= kh * H.col(currentUserIndex);
202 H.col(currentUserIndex++) += u * deltaH;
203 currentUserIndex = currentUserIndex % V.n_cols;
This class computes SVD using incomplete incremental batch learning, as described in the following pa...
SVDIncompleteIncrementalLearning(double u=0.001, double kw=0, double kh=0)
Initialize the parameters of SVDIncompleteIncrementalLearning.
void HUpdate(const MatType &V, const arma::mat &W, arma::mat &H)
The update rule for the encoding matrix H.
void WUpdate(const MatType &V, arma::mat &W, const arma::mat &H)
The update rule for the basis matrix W.
void Initialize(const MatType &, const size_t)
Initialize parameters before factorization.