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,
109 double Optimize(arma::mat& iterate);
112 const DecomposableFunctionType&
Function()
const {
return function; }
114 DecomposableFunctionType&
Function() {
return function; }
138 DecomposableFunctionType&
function;
158 #include "sgd_impl.hpp" bool Shuffle() const
Get whether or not the individual functions are shuffled.
double tolerance
The tolerance for termination.
double & Tolerance()
Modify the tolerance for termination.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Tolerance() const
Get the tolerance for termination.
double stepSize
The step size for each example.
size_t maxIterations
The maximum number of allowed iterations.
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.
double StepSize() const
Get the step size.
const DecomposableFunctionType & Function() const
Get the instantiated function to be optimized.
bool & Shuffle()
Modify whether or not the individual functions are shuffled.
double & StepSize()
Modify the step size.
size_t & MaxIterations()
Modify the maximum number of iterations (0 indicates no limit).
size_t MaxIterations() const
Get the maximum number of iterations (0 indicates no limit).
bool shuffle
Controls whether or not the individual functions are shuffled when iterating.
DecomposableFunctionType & Function()
Modify the instantiated function.
Stochastic Gradient Descent is a technique for minimizing a function which can be expressed as a sum ...
double Optimize(arma::mat &iterate)
Optimize the given function using stochastic gradient descent.