svdplusplus_function.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_SVDPLUSPLUS_SVDPLUSPLUS_FUNCTION_HPP
15 #define MLPACK_METHODS_SVDPLUSPLUS_SVDPLUSPLUS_FUNCTION_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 #include <ensmallen.hpp>
19 
20 namespace mlpack {
21 namespace svd {
22 
30 template <typename MatType = arma::mat>
32 {
33  public:
45  SVDPlusPlusFunction(const MatType& data,
46  const arma::sp_mat& implicitData,
47  const size_t rank,
48  const double lambda);
49 
53  void Shuffle();
54 
61  double Evaluate(const arma::mat& parameters) const;
62 
72  double Evaluate(const arma::mat& parameters,
73  const size_t start,
74  const size_t batchSize = 1) const;
75 
84  void Gradient(const arma::mat& parameters,
85  arma::mat& gradient) const;
86 
100  template <typename GradType>
101  void Gradient(const arma::mat& parameters,
102  const size_t start,
103  GradType& gradient,
104  const size_t batchSize = 1) const;
105 
107  const arma::mat& GetInitialPoint() const { return initialPoint; }
108 
110  const arma::mat& Dataset() const { return data; }
111 
113  const arma::sp_mat& ImplicitDataset() const { return implicitData; }
114 
116  size_t NumFunctions() const { return data.n_cols; }
117 
119  size_t NumUsers() const { return numUsers; }
120 
122  size_t NumItems() const { return numItems; }
123 
125  double Lambda() const { return lambda; }
126 
128  size_t Rank() const { return rank; }
129 
130  private:
132  MatType data;
134  arma::sp_mat implicitData;
136  arma::mat initialPoint;
138  size_t rank;
140  double lambda;
142  size_t numUsers;
144  size_t numItems;
145 };
146 
147 } // namespace svd
148 } // namespace mlpack
149 
154 namespace ens {
155 
162  template <>
163  template <>
164  inline double StandardSGD::Optimize(
166  arma::mat& parameters);
167 
168  template <>
169  template <>
170  inline double ParallelSGD<ExponentialBackoff>::Optimize(
172  arma::mat& parameters);
173 
174 } // namespace ens
175 
179 #include "svdplusplus_function_impl.hpp"
180 
181 #endif
This class contains methods which are used to calculate the cost of SVD++&#39;s objective function...
double Evaluate(const arma::mat &parameters) const
Evaluates the cost function over all examples in the data.
Linear algebra utility functions, generally performed on matrices or vectors.
const arma::sp_mat & ImplicitDataset() const
Return the implicit data passed into the constructor.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t NumItems() const
Return the number of items in the data.
void Shuffle()
Shuffle the points in the dataset.
size_t Rank() const
Return the rank used for the factorization.
size_t NumFunctions() const
Return the number of training examples. Useful for SGD optimizer.
void Gradient(const arma::mat &parameters, arma::mat &gradient) const
Evaluates the full gradient of the cost function over all the training examples.
const arma::mat & Dataset() const
Return the dataset passed into the constructor.
size_t NumUsers() const
Return the number of users in the data.
SVDPlusPlusFunction(const MatType &data, const arma::sp_mat &implicitData, const size_t rank, const double lambda)
Constructor for SVDPlusPlusFunction class.
const arma::mat & GetInitialPoint() const
Return the initial point for the optimization.
double Lambda() const
Return the regularization parameters.