mlpack 3.4.2
bias_svd_function.hpp
Go to the documentation of this file.
1
14#ifndef MLPACK_METHODS_BIAS_SVD_BIAS_SVD_FUNCTION_HPP
15#define MLPACK_METHODS_BIAS_SVD_BIAS_SVD_FUNCTION_HPP
16
17#include <mlpack/prereqs.hpp>
18#include <ensmallen.hpp>
19
20namespace mlpack {
21namespace svd {
22
30template <typename MatType = arma::mat>
32{
33 public:
43 BiasSVDFunction(const MatType& data,
44 const size_t rank,
45 const double lambda);
46
50 void Shuffle();
51
58 double Evaluate(const arma::mat& parameters) const;
59
69 double Evaluate(const arma::mat& parameters,
70 const size_t start,
71 const size_t batchSize = 1) const;
72
81 void Gradient(const arma::mat& parameters,
82 arma::mat& gradient) const;
83
97 template <typename GradType>
98 void Gradient(const arma::mat& parameters,
99 const size_t start,
100 GradType& gradient,
101 const size_t batchSize = 1) const;
102
104 const arma::mat& GetInitialPoint() const { return initialPoint; }
105
107 const arma::mat& Dataset() const { return data; }
108
110 size_t NumFunctions() const { return data.n_cols; }
111
113 size_t NumUsers() const { return numUsers; }
114
116 size_t NumItems() const { return numItems; }
117
119 double Lambda() const { return lambda; }
120
122 size_t Rank() const { return rank; }
123
124 private:
126 MatType data;
128 arma::mat initialPoint;
130 size_t rank;
132 double lambda;
134 size_t numUsers;
136 size_t numItems;
137};
138
139} // namespace svd
140} // namespace mlpack
141
146namespace ens {
147
154 template <>
155 template <>
156 inline double StandardSGD::Optimize(
158 arma::mat& parameters);
159
160 template <>
161 template <>
162 inline double ParallelSGD<ExponentialBackoff>::Optimize(
164 arma::mat& parameters);
165
166} // namespace ens
167
172#include "bias_svd_function_impl.hpp"
173
174#endif
This class contains methods which are used to calculate the cost of BiasSVD's objective function,...
double Evaluate(const arma::mat &parameters, const size_t start, const size_t batchSize=1) const
Evaluates the cost function for one training example.
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.
void Shuffle()
Shuffle the points in the dataset.
double Lambda() const
Return the regularization parameters.
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.
double Evaluate(const arma::mat &parameters) const
Evaluates the cost function over all examples in the data.
const arma::mat & GetInitialPoint() const
Return the initial point for the optimization.
void Gradient(const arma::mat &parameters, arma::mat &gradient) const
Evaluates the full gradient of the cost function over all the training examples.
BiasSVDFunction(const MatType &data, const size_t rank, const double lambda)
Constructor for BiasSVDFunction class.
size_t NumItems() const
Return the number of items in the data.
size_t NumUsers() const
Return the number of users in the data.
size_t Rank() const
Return the rank used for the factorization.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.