1 #ifndef SVD_COMPLETE_INCREMENTAL_LEARNING_HPP_INCLUDED
2 #define SVD_COMPLETE_INCREMENTAL_LEARNING_HPP_INCLUDED
11 template <
class MatType>
21 void Initialize(
const MatType& dataset,
const size_t rank)
51 arma::mat deltaW(1, W.n_cols);
87 arma::mat deltaH(H.n_rows, 1);
136 void Initialize(
const arma::sp_mat& dataset,
const size_t rank)
142 it =
new arma::sp_mat::const_iterator(dataset.begin());
159 if(!isStart) (*it)++;
160 else isStart =
false;
165 it =
new arma::sp_mat::const_iterator(V.begin());
171 arma::mat deltaW(1, W.n_cols);
174 deltaW += (**it - arma::dot(W.row(currentItemIndex), H.col(currentUserIndex)))
175 * arma::trans(H.col(currentUserIndex));
176 if(
kw != 0) deltaW -=
kw * W.row(currentItemIndex);
178 W.row(currentItemIndex) +=
u*deltaW;
196 arma::mat deltaH(H.n_rows, 1);
202 deltaH += (**it - arma::dot(W.row(currentItemIndex), H.col(currentUserIndex)))
203 * arma::trans(W.row(currentItemIndex));
204 if(
kh != 0) deltaH -=
kh * H.col(currentUserIndex);
206 H.col(currentUserIndex++) +=
u * deltaH;
218 arma::sp_mat::const_iterator*
it;
227 #endif // SVD_COMPLETE_INCREMENTAL_LEARNING_HPP_INCLUDED
void HUpdate(const arma::sp_mat &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.
Linear algebra utility functions, generally performed on matrices or vectors.
void HUpdate(const MatType &V, const arma::mat &W, arma::mat &H)
The update rule for the encoding matrix H.
~SVDCompleteIncrementalLearning()
arma::sp_mat::const_iterator * it
void WUpdate(const arma::sp_mat &V, arma::mat &W, const arma::mat &H)
The update rule for the basis matrix W.
SVDCompleteIncrementalLearning(double u=0.0001, double kw=0, double kh=0)
SVDCompleteIncrementalLearning(double u=0.01, double kw=0, double kh=0)
void Initialize(const MatType &dataset, const size_t rank)
void Initialize(const arma::sp_mat &dataset, const size_t rank)