14 #ifndef __MLPACK_CORE_OPTIMIZERS_SGD_SGD_HPP 15 #define __MLPACK_CORE_OPTIMIZERS_SGD_SGD_HPP 20 namespace optimization {
77 template<
typename DecomposableFunctionType>
92 SGD(DecomposableFunctionType&
function,
106 double Optimize(arma::mat& iterate);
109 const DecomposableFunctionType&
Function()
const {
return function; }
111 DecomposableFunctionType&
Function() {
return function; }
135 DecomposableFunctionType&
function;
155 #include "sgd_impl.hpp" double tolerance
The tolerance for termination.
double & Tolerance()
Modify the tolerance for termination.
Linear algebra utility functions, generally performed on matrices or vectors.
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.
bool & Shuffle()
Modify whether or not the individual functions are shuffled.
double Tolerance() const
Get the tolerance for termination.
double & StepSize()
Modify the step size.
bool Shuffle() const
Get whether or not the individual functions are shuffled.
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.
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.
size_t MaxIterations() const
Get the maximum number of iterations (0 indicates no limit).
const DecomposableFunctionType & Function() const
Get the instantiated function to be optimized.