scd.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_CORE_OPTIMIZERS_SCD_SCD_HPP
13 #define MLPACK_CORE_OPTIMIZERS_SCD_SCD_HPP
14 
15 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace optimization {
20 
61 template <typename DescentPolicyType = RandomDescent>
62 class SCD
63 {
64  public:
82  SCD(const double stepSize = 0.01,
83  const size_t maxIterations = 100000,
84  const double tolerance = 1e-5,
85  const size_t updateInterval = 1e3,
86  const DescentPolicyType descentPolicy = DescentPolicyType());
87 
98  template <typename ResolvableFunctionType>
99  double Optimize(ResolvableFunctionType& function, arma::mat& iterate);
100 
102  double StepSize() const { return stepSize; }
104  double& StepSize() { return stepSize; }
105 
107  size_t MaxIterations() const { return maxIterations; }
109  size_t& MaxIterations() { return maxIterations; }
110 
112  double Tolerance() const { return tolerance; }
114  double& Tolerance() { return tolerance; }
115 
117  size_t UpdateInterval() const { return updateInterval; }
119  size_t& UpdateInterval() { return updateInterval; }
120 
122  DescentPolicyType DescentPolicy() const { return descentPolicy; }
124  DescentPolicyType& DescentPolicy() { return descentPolicy; }
125 
126  private:
128  double stepSize;
129 
131  size_t maxIterations;
132 
134  double tolerance;
135 
137  size_t updateInterval;
138 
140  DescentPolicyType descentPolicy;
141 };
142 
143 } // namespace optimization
144 } // namespace mlpack
145 
146 // Include implementation.
147 #include "scd_impl.hpp"
148 
149 #endif
double StepSize() const
Get the step size.
Definition: scd.hpp:102
SCD(const double stepSize=0.01, const size_t maxIterations=100000, const double tolerance=1e-5, const size_t updateInterval=1e3, const DescentPolicyType descentPolicy=DescentPolicyType())
Construct the SCD optimizer with the given function and parameters.
.hpp
Definition: add_to_po.hpp:21
double & StepSize()
Modify the step size.
Definition: scd.hpp:104
size_t MaxIterations() const
Get the maximum number of iterations (0 indicates no limit).
Definition: scd.hpp:107
The core includes that mlpack expects; standard C++ includes and Armadillo.
Stochastic Coordinate descent is a technique for minimizing a function by doing a line search along a...
Definition: scd.hpp:62
DescentPolicyType DescentPolicy() const
Get the descent policy.
Definition: scd.hpp:122
size_t & UpdateInterval()
Modify the update interval for reporting objective.
Definition: scd.hpp:119
double Optimize(ResolvableFunctionType &function, arma::mat &iterate)
Optimize the given function using stochastic coordinate descent.
size_t UpdateInterval() const
Get the update interval for reporting objective.
Definition: scd.hpp:117
double & Tolerance()
Modify the tolerance for termination.
Definition: scd.hpp:114
double Tolerance() const
Get the tolerance for termination.
Definition: scd.hpp:112
size_t & MaxIterations()
Modify the maximum number of iterations (0 indicates no limit).
Definition: scd.hpp:109
DescentPolicyType & DescentPolicy()
Modify the descent policy.
Definition: scd.hpp:124