12 #ifndef MLPACK_CORE_OPTIMIZERS_SGD_SGD_HPP
13 #define MLPACK_CORE_OPTIMIZERS_SGD_SGD_HPP
18 namespace optimization {
75 template<
typename DecomposableFunctionType>
95 SGD(DecomposableFunctionType&
function,
96 const double stepSize = 0.01,
97 const size_t maxIterations = 100000,
98 const double tolerance = 1e-5,
99 const bool shuffle =
true);
109 double Optimize(arma::mat& iterate);
112 const DecomposableFunctionType&
Function()
const {
return function; }
114 DecomposableFunctionType&
Function() {
return function; }
138 DecomposableFunctionType&
function;
144 size_t maxIterations;
158 #include "sgd_impl.hpp"
bool Shuffle() const
Get whether or not the individual functions are shuffled.
SGD(DecomposableFunctionType &function, const double stepSize=0.01, const size_t maxIterations=100000, const double tolerance=1e-5, const bool shuffle=true)
Construct the SGD optimizer with the given function and parameters.
bool & Shuffle()
Modify whether or not the individual functions are shuffled.
The core includes that mlpack expects; standard C++ includes and Armadillo.
const DecomposableFunctionType & Function() const
Get the instantiated function to be optimized.
double Optimize(arma::mat &iterate)
Optimize the given function using stochastic gradient descent.
size_t & MaxIterations()
Modify the maximum number of iterations (0 indicates no limit).
double & StepSize()
Modify the step size.
DecomposableFunctionType & Function()
Modify the instantiated function.
Stochastic Gradient Descent is a technique for minimizing a function which can be expressed as a sum ...
double StepSize() const
Get the step size.
double & Tolerance()
Modify the tolerance for termination.
double Tolerance() const
Get the tolerance for termination.
size_t MaxIterations() const
Get the maximum number of iterations (0 indicates no limit).