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>
|
| 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 ¶meters) const |
| Evaluates the cost function over all examples in the data. More...
|
|
double | Evaluate (const arma::mat ¶meters, const size_t start, const size_t batchSize=1) const |
| Evaluates the cost function for one training example. More...
|
|
void | Gradient (const arma::mat ¶meters, 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 ¶meters, 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.
|
|
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
-
MatType | The matrix type of the dataset. |
◆ BiasSVDFunction()
template<typename MatType >
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
-
data | Dataset for which SVD is calculated. |
rank | Rank used for matrix factorization. |
lambda | Regularization parameter used for optimization. |
◆ Evaluate() [1/2]
template<typename MatType >
Evaluates the cost function over all examples in the data.
- Parameters
-
parameters | Parameters(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
-
parameters | Parameters(user/item matrices/bias) of the decomposition. |
start | First index of the training examples to be used. |
batchSize | Size of batch to evaluate. |
◆ Gradient() [1/2]
template<typename MatType >
Evaluates the full gradient of the cost function over all the training examples.
- Parameters
-
parameters | Parameters(user/item matrices/bias) of the decomposition. |
gradient | Calculated 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
-
GradType | The type of the gradient out-param. |
- Parameters
-
parameters | Parameters(user/item matrices/bias) of the decomposition. |
start | The first index of the training examples to use. |
gradient | Calculated gradient for the parameters. |
batchSize | Size of batch to calculate gradient for. |
◆ Shuffle()
template<typename MatType >
Shuffle the points in the dataset.
This may be used by optimizers.
The documentation for this class was generated from the following files: