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" 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() const
Get whether or not the individual functions are shuffled.
Linear algebra utility functions, generally performed on matrices or vectors.
bool & Shuffle()
Modify whether or not the individual functions are shuffled.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Tolerance() const
Get the tolerance for termination.
double Optimize(arma::mat &iterate)
Optimize the given function using stochastic gradient descent.
size_t MaxIterations() const
Get the maximum number of iterations (0 indicates no limit).
double StepSize() const
Get the step size.
size_t & MaxIterations()
Modify the maximum number of iterations (0 indicates no limit).
const DecomposableFunctionType & Function() const
Get the instantiated function to be optimized.
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 & Tolerance()
Modify the tolerance for termination.