mlpack
Public Member Functions | List of all members
mlpack::svd::BiasSVDFunction< MatType > Class Template Reference

This class contains methods which are used to calculate the cost of BiasSVD's objective function, to calculate gradient of parameters with respect to the objective function, etc. More...

#include <bias_svd_function.hpp>

Public Member Functions

 BiasSVDFunction (const MatType &data, const size_t rank, const double lambda)
 Constructor for BiasSVDFunction class. More...
 
void Shuffle ()
 Shuffle the points in the dataset. More...
 
double Evaluate (const arma::mat &parameters) const
 Evaluates the cost function over all examples in the data. More...
 
double Evaluate (const arma::mat &parameters, const size_t start, const size_t batchSize=1) const
 Evaluates the cost function for one training example. More...
 
void Gradient (const arma::mat &parameters, arma::mat &gradient) const
 Evaluates the full gradient of the cost function over all the training examples. More...
 
template<typename GradType >
void Gradient (const arma::mat &parameters, const size_t start, GradType &gradient, const size_t batchSize=1) const
 Evaluates the gradient of the cost function over one training example. More...
 
const arma::mat & GetInitialPoint () const
 Return the initial point for the optimization.
 
const arma::mat & Dataset () const
 Return the dataset passed into the constructor.
 
size_t NumFunctions () const
 Return the number of training examples. Useful for SGD optimizer.
 
size_t NumUsers () const
 Return the number of users in the data.
 
size_t NumItems () const
 Return the number of items in the data.
 
double Lambda () const
 Return the regularization parameters.
 
size_t Rank () const
 Return the rank used for the factorization.
 

Detailed Description

template<typename MatType = arma::mat>
class mlpack::svd::BiasSVDFunction< MatType >

This class contains methods which are used to calculate the cost of BiasSVD's objective function, to calculate gradient of parameters with respect to the objective function, etc.

Template Parameters
MatTypeThe matrix type of the dataset.

Constructor & Destructor Documentation

◆ BiasSVDFunction()

template<typename MatType >
mlpack::svd::BiasSVDFunction< MatType >::BiasSVDFunction ( const MatType &  data,
const size_t  rank,
const double  lambda 
)

Constructor for BiasSVDFunction class.

The constructor calculates the number of users and items in the passed data. It also randomly initializes the parameter values.

Parameters
dataDataset for which SVD is calculated.
rankRank used for matrix factorization.
lambdaRegularization parameter used for optimization.

Member Function Documentation

◆ Evaluate() [1/2]

template<typename MatType >
double mlpack::svd::BiasSVDFunction< MatType >::Evaluate ( const arma::mat &  parameters) const

Evaluates the cost function over all examples in the data.

Parameters
parametersParameters(user/item matrices/bias) of the decomposition.

◆ Evaluate() [2/2]

template<typename MatType >
double mlpack::svd::BiasSVDFunction< MatType >::Evaluate ( const arma::mat &  parameters,
const size_t  start,
const size_t  batchSize = 1 
) const

Evaluates the cost function for one training example.

Useful for the SGD optimizer abstraction which uses one training example at a time.

Parameters
parametersParameters(user/item matrices/bias) of the decomposition.
startFirst index of the training examples to be used.
batchSizeSize of batch to evaluate.

◆ Gradient() [1/2]

template<typename MatType >
void mlpack::svd::BiasSVDFunction< MatType >::Gradient ( const arma::mat &  parameters,
arma::mat &  gradient 
) const

Evaluates the full gradient of the cost function over all the training examples.

Parameters
parametersParameters(user/item matrices/bias) of the decomposition.
gradientCalculated gradient for the parameters.

◆ Gradient() [2/2]

template<typename MatType >
template<typename GradType >
void mlpack::svd::BiasSVDFunction< MatType >::Gradient ( const arma::mat &  parameters,
const size_t  start,
GradType &  gradient,
const size_t  batchSize = 1 
) const

Evaluates the gradient of the cost function over one training example.

This function is useful for optimizers like SGD. The type of the gradient parameter is a template argument to allow the computation of a sparse gradient.

Template Parameters
GradTypeThe type of the gradient out-param.
Parameters
parametersParameters(user/item matrices/bias) of the decomposition.
startThe first index of the training examples to use.
gradientCalculated gradient for the parameters.
batchSizeSize of batch to calculate gradient for.

◆ Shuffle()

template<typename MatType >
void mlpack::svd::BiasSVDFunction< MatType >::Shuffle ( )

Shuffle the points in the dataset.

This may be used by optimizers.


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