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"
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.
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.
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).
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.