MLPACK  1.0.4
sgd.hpp
Go to the documentation of this file.
00001 
00022 #ifndef __MLPACK_CORE_OPTIMIZERS_SGD_SGD_HPP
00023 #define __MLPACK_CORE_OPTIMIZERS_SGD_SGD_HPP
00024 
00025 namespace mlpack {
00026 namespace optimization {
00027 
00083 template<typename DecomposableFunctionType>
00084 class SGD
00085 {
00086  public:
00098   SGD(DecomposableFunctionType& function,
00099       const double stepSize = 0.01,
00100       const size_t maxIterations = 100000,
00101       const double tolerance = 1e-5,
00102       const bool shuffle = true);
00103 
00112   double Optimize(arma::mat& iterate);
00113 
00115   const DecomposableFunctionType& Function() const { return function; }
00117   DecomposableFunctionType& Function() { return function; }
00118 
00120   double StepSize() const { return stepSize; }
00122   double& StepSize() { return stepSize; }
00123 
00125   size_t MaxIterations() const { return maxIterations; }
00127   size_t& MaxIterations() { return maxIterations; }
00128 
00130   double Tolerance() const { return tolerance; }
00132   double& Tolerance() { return tolerance; }
00133 
00135   bool Shuffle() const { return shuffle; }
00137   bool& Shuffle() { return shuffle; }
00138 
00139  private:
00141   DecomposableFunctionType& function;
00142 
00144   double stepSize;
00145 
00147   size_t maxIterations;
00148 
00150   double tolerance;
00151 
00154   bool shuffle;
00155 };
00156 
00157 }; // namespace optimization
00158 }; // namespace mlpack
00159 
00160 // Include implementation.
00161 #include "sgd_impl.hpp"
00162 
00163 #endif