gradient_descent.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_CORE_OPTIMIZERS_GRADIENT_DESCENT_GRADIENT_DESCENT_HPP
13 #define MLPACK_CORE_OPTIMIZERS_GRADIENT_DESCENT_GRADIENT_DESCENT_HPP
14 
15 #include <mlpack/core.hpp>
16 
17 namespace mlpack {
18 namespace optimization {
19 
50 {
51  public:
64  GradientDescent(const double stepSize = 0.01,
65  const size_t maxIterations = 100000,
66  const double tolerance = 1e-5);
67 
78  template<typename FunctionType>
79  double Optimize(FunctionType& function, arma::mat& iterate);
80 
96  template<typename FunctionType>
97  double Optimize(
98  FunctionType& function,
99  arma::mat& iterate,
101 
103  double StepSize() const { return stepSize; }
105  double& StepSize() { return stepSize; }
106 
108  size_t MaxIterations() const { return maxIterations; }
110  size_t& MaxIterations() { return maxIterations; }
111 
113  double Tolerance() const { return tolerance; }
115  double& Tolerance() { return tolerance; }
116 
117  private:
119  double stepSize;
120 
122  size_t maxIterations;
123 
125  double tolerance;
126 };
127 
128 } // namespace optimization
129 } // namespace mlpack
130 
131 #include "gradient_descent_impl.hpp"
132 
133 #endif
GradientDescent(const double stepSize=0.01, const size_t maxIterations=100000, const double tolerance=1e-5)
Construct the Gradient Descent optimizer with the given function and parameters.
Auxiliary information for a dataset, including mappings to/from strings (or other types) and the data...
double Optimize(FunctionType &function, arma::mat &iterate)
Optimize the given function using gradient descent.
.hpp
Definition: add_to_po.hpp:21
size_t MaxIterations() const
Get the maximum number of iterations (0 indicates no limit).
double & Tolerance()
Modify the tolerance for termination.
Gradient Descent is a technique to minimize a function.
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
size_t & MaxIterations()
Modify the maximum number of iterations (0 indicates no limit).
double StepSize() const
Get the step size.
double & StepSize()
Modify the step size.
double Tolerance() const
Get the tolerance for termination.