mlpack  master
rmsprop.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_OPTIMIZERS_RMSPROP_RMSPROP_HPP
15 #define MLPACK_CORE_OPTIMIZERS_RMSPROP_RMSPROP_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace optimization {
21 
63 template<typename DecomposableFunctionType>
64 class RMSprop
65 {
66  public:
86  RMSprop(DecomposableFunctionType& function,
87  const double stepSize = 0.01,
88  const double alpha = 0.99,
89  const double eps = 1e-8,
90  const size_t maxIterations = 100000,
91  const double tolerance = 1e-5,
92  const bool shuffle = true);
93 
102  double Optimize(arma::mat& iterate);
103 
105  const DecomposableFunctionType& Function() const { return function; }
107  DecomposableFunctionType& Function() { return function; }
108 
110  double StepSize() const { return stepSize; }
112  double& StepSize() { return stepSize; }
113 
115  double Alpha() const { return alpha; }
117  double& Alpha() { return alpha; }
118 
120  double Epsilon() const { return eps; }
122  double& Epsilon() { return eps; }
123 
125  size_t MaxIterations() const { return maxIterations; }
127  size_t& MaxIterations() { return maxIterations; }
128 
130  double Tolerance() const { return tolerance; }
132  double& Tolerance() { return tolerance; }
133 
135  bool Shuffle() const { return shuffle; }
137  bool& Shuffle() { return shuffle; }
138 
139  private:
141  DecomposableFunctionType& function;
142 
144  double stepSize;
145 
147  double alpha;
148 
150  double eps;
151 
154 
156  double tolerance;
157 
160  bool shuffle;
161 };
162 
163 } // namespace optimization
164 } // namespace mlpack
165 
166 // Include implementation.
167 #include "rmsprop_impl.hpp"
168 
169 #endif
double & Alpha()
Modify the smoothing parameter.
Definition: rmsprop.hpp:117
double Alpha() const
Get the smoothing parameter.
Definition: rmsprop.hpp:115
RMSprop(DecomposableFunctionType &function, const double stepSize=0.01, const double alpha=0.99, const double eps=1e-8, const size_t maxIterations=100000, const double tolerance=1e-5, const bool shuffle=true)
Construct the RMSprop optimizer with the given function and parameters.
bool & Shuffle()
Modify whether or not the individual functions are shuffled.
Definition: rmsprop.hpp:137
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
size_t maxIterations
The maximum number of allowed iterations.
Definition: rmsprop.hpp:153
The core includes that mlpack expects; standard C++ includes and Armadillo.
double eps
The value used to initialise the mean squared gradient parameter.
Definition: rmsprop.hpp:150
double tolerance
The tolerance for termination.
Definition: rmsprop.hpp:156
double StepSize() const
Get the step size.
Definition: rmsprop.hpp:110
bool shuffle
Controls whether or not the individual functions are shuffled when iterating.
Definition: rmsprop.hpp:160
double alpha
The smoothing parameter.
Definition: rmsprop.hpp:147
size_t & MaxIterations()
Modify the maximum number of iterations (0 indicates no limit).
Definition: rmsprop.hpp:127
const DecomposableFunctionType & Function() const
Get the instantiated function to be optimized.
Definition: rmsprop.hpp:105
double stepSize
The step size for each example.
Definition: rmsprop.hpp:144
DecomposableFunctionType & Function()
Modify the instantiated function.
Definition: rmsprop.hpp:107
double & Tolerance()
Modify the tolerance for termination.
Definition: rmsprop.hpp:132
double Epsilon() const
Get the value used to initialise the mean squared gradient parameter.
Definition: rmsprop.hpp:120
double Optimize(arma::mat &iterate)
Optimize the given function using RMSprop.
double & Epsilon()
Modify the value used to initialise the mean squared gradient parameter.
Definition: rmsprop.hpp:122
bool Shuffle() const
Get whether or not the individual functions are shuffled.
Definition: rmsprop.hpp:135
RMSprop is an optimizer that utilizes the magnitude of recent gradients to normalize the gradients...
Definition: rmsprop.hpp:64
size_t MaxIterations() const
Get the maximum number of iterations (0 indicates no limit).
Definition: rmsprop.hpp:125
double & StepSize()
Modify the step size.
Definition: rmsprop.hpp:112
double Tolerance() const
Get the tolerance for termination.
Definition: rmsprop.hpp:130