mlpack  master
Public Member Functions | Private Attributes | List of all members
mlpack::amf::SVDBatchLearning Class Reference

This class implements SVD batch learning with momentum. More...

Public Member Functions

 SVDBatchLearning (double u=0.0002, double kw=0, double kh=0, double momentum=0.9)
 SVD Batch learning constructor. More...
 
template<typename MatType >
void HUpdate (const MatType &V, const arma::mat &W, arma::mat &H)
 The update rule for the encoding matrix H. More...
 
template<typename MatType >
void Initialize (const MatType &dataset, const size_t rank)
 Initialize parameters before factorization. More...
 
template<typename Archive >
void Serialize (Archive &ar, const unsigned int)
 Serialize the SVDBatch object. More...
 
template<typename MatType >
void WUpdate (const MatType &V, arma::mat &W, const arma::mat &H)
 The update rule for the basis matrix W. More...
 

Private Attributes

double kh
 Regularization parameter for matrix H. More...
 
double kw
 Regularization parameter for matrix W. More...
 
arma::mat mH
 Momentum matrix for matrix H. More...
 
double momentum
 Momentum value (between 0 and 1). More...
 
arma::mat mW
 Momentum matrix for matrix W. More...
 
double u
 Step size of the algorithm. More...
 

Detailed Description

This class implements SVD batch learning with momentum.

This procedure is described in the following paper:

@techreport{ma2008guide,
title={A Guide to Singular Value Decomposition for Collaborative
Filtering},
author={Ma, Chih-Chao},
year={2008},
institution={Department of Computer Science, National Taiwan University}
}

This class implements 'Algorithm 4' as given in the paper.

The factorizer decomposes the matrix V into two matrices W and H such that sum of sum of squared error between V and W * H is minimum. This optimization is performed with gradient descent. To make gradient descent faster, momentum is added.

Definition at line 41 of file svd_batch_learning.hpp.

Constructor & Destructor Documentation

mlpack::amf::SVDBatchLearning::SVDBatchLearning ( double  u = 0.0002,
double  kw = 0,
double  kh = 0,
double  momentum = 0.9 
)
inline

SVD Batch learning constructor.

Parameters
ustep value used in batch learning
kwregularization constant for W matrix
khregularization constant for H matrix
momentummomentum applied to batch learning process

Definition at line 52 of file svd_batch_learning.hpp.

Member Function Documentation

template<typename MatType >
void mlpack::amf::SVDBatchLearning::HUpdate ( const MatType &  V,
const arma::mat &  W,
arma::mat &  H 
)
inline

The update rule for the encoding matrix H.

The function takes in all the matrices and only changes the value of the H matrix.

Parameters
VInput matrix to be factorized.
WBasis matrix.
HEncoding matrix to be updated.

Definition at line 133 of file svd_batch_learning.hpp.

References kh, mH, momentum, and u.

template<typename MatType >
void mlpack::amf::SVDBatchLearning::Initialize ( const MatType &  dataset,
const size_t  rank 
)
inline

Initialize parameters before factorization.

This function must be called before a new factorization. This resets the internally-held momentum.

Parameters
datasetInput matrix to be factorized.
rankrank of factorization

Definition at line 69 of file svd_batch_learning.hpp.

References mH, and mW.

template<typename Archive >
void mlpack::amf::SVDBatchLearning::Serialize ( Archive &  ar,
const unsigned  int 
)
inline

Serialize the SVDBatch object.

Definition at line 169 of file svd_batch_learning.hpp.

References mlpack::data::CreateNVP(), kh, kw, mH, momentum, mW, and u.

template<typename MatType >
void mlpack::amf::SVDBatchLearning::WUpdate ( const MatType &  V,
arma::mat &  W,
const arma::mat &  H 
)
inline

The update rule for the basis matrix W.

The function takes in all the matrices and only changes the value of the W matrix.

Parameters
VInput matrix to be factorized.
WBasis matrix to be updated.
HEncoding matrix.

Definition at line 88 of file svd_batch_learning.hpp.

References kw, momentum, mW, and u.

Member Data Documentation

double mlpack::amf::SVDBatchLearning::kh
private

Regularization parameter for matrix H.

Definition at line 186 of file svd_batch_learning.hpp.

Referenced by HUpdate(), Serialize(), and mlpack::amf::SVDBatchLearning::HUpdate< arma::sp_mat >().

double mlpack::amf::SVDBatchLearning::kw
private

Regularization parameter for matrix W.

Definition at line 184 of file svd_batch_learning.hpp.

Referenced by Serialize(), mlpack::amf::SVDBatchLearning::WUpdate< arma::sp_mat >(), and WUpdate().

arma::mat mlpack::amf::SVDBatchLearning::mH
private

Momentum matrix for matrix H.

Definition at line 193 of file svd_batch_learning.hpp.

Referenced by HUpdate(), Initialize(), Serialize(), and mlpack::amf::SVDBatchLearning::HUpdate< arma::sp_mat >().

double mlpack::amf::SVDBatchLearning::momentum
private
arma::mat mlpack::amf::SVDBatchLearning::mW
private

Momentum matrix for matrix W.

Definition at line 191 of file svd_batch_learning.hpp.

Referenced by Initialize(), Serialize(), mlpack::amf::SVDBatchLearning::WUpdate< arma::sp_mat >(), and WUpdate().

double mlpack::amf::SVDBatchLearning::u
private

The documentation for this class was generated from the following file: