14 #ifndef __MLPACK_METHODS_AMF_SVD_INCOMPLETE_INCREMENTAL_LEARNING_HPP
15 #define __MLPACK_METHODS_AMF_SVD_INCOMPLETE_INCREMENTAL_LEARNING_HPP
71 template<
typename MatType>
87 template<
typename MatType>
93 deltaW.zeros(V.n_rows, W.n_cols);
97 for (
size_t i = 0; i < V.n_rows; ++i)
106 deltaW.row(i) -=
kw * W.row(i);
120 template<
typename MatType>
126 deltaH.zeros(H.n_rows);
130 for (
size_t i = 0; i < V.n_rows; ++i)
164 inline void SVDIncompleteIncrementalLearning::
165 WUpdate<arma::sp_mat>(
const arma::sp_mat& V,
169 arma::mat deltaW(V.n_rows, W.n_cols);
171 for(arma::sp_mat::const_iterator it = V.begin_col(currentUserIndex);
172 it != V.end_col(currentUserIndex);it++)
176 deltaW.row(i) += (val - arma::dot(W.row(i), H.col(currentUserIndex))) *
177 arma::trans(H.col(currentUserIndex));
178 if(kw != 0) deltaW.row(i) -= kw * W.row(i);
185 inline void SVDIncompleteIncrementalLearning::
186 HUpdate<arma::sp_mat>(
const arma::sp_mat& V,
190 arma::mat deltaH(H.n_rows, 1);
193 for(arma::sp_mat::const_iterator it = V.begin_col(currentUserIndex);
194 it != V.end_col(currentUserIndex);it++)
198 if((val = V(i, currentUserIndex)) != 0)
199 deltaH += (val - arma::dot(W.row(i), H.col(currentUserIndex))) *
200 arma::trans(W.row(i));
202 if(kh != 0) deltaH -= kh * H.col(currentUserIndex);
204 H.col(currentUserIndex++) += u * deltaH;
205 currentUserIndex = currentUserIndex % V.n_cols;
size_t currentUserIndex
Current user under consideration.
This class computes SVD using incomplete incremental batch learning, as described in the following pa...
Linear algebra utility functions, generally performed on matrices or vectors.
double u
Step size of batch learning.
double kh
Regularization parameter for H matrix.
void WUpdate(const MatType &V, arma::mat &W, const arma::mat &H)
The update rule for the basis matrix W.
double kw
Regularization parameter for W matrix.
void HUpdate(const MatType &V, const arma::mat &W, arma::mat &H)
The update rule for the encoding matrix H.
void Initialize(const MatType &, const size_t)
Initialize parameters before factorization.
SVDIncompleteIncrementalLearning(double u=0.001, double kw=0, double kh=0)
Initialize the parameters of SVDIncompleteIncrementalLearning.