rmsprop_update.hpp
Go to the documentation of this file.
1 
15 #ifndef MLPACK_CORE_OPTIMIZERS_RMSPROP_RMSPROP_UPDATE_HPP
16 #define MLPACK_CORE_OPTIMIZERS_RMSPROP_RMSPROP_UPDATE_HPP
17 
18 #include <mlpack/prereqs.hpp>
19 
20 namespace mlpack {
21 namespace optimization {
22 
45 {
46  public:
54  RMSPropUpdate(const double epsilon = 1e-8,
55  const double alpha = 0.99) :
56  epsilon(epsilon),
57  alpha(alpha)
58  {
59  // Nothing to do.
60  }
61 
69  void Initialize(const size_t rows, const size_t cols)
70  {
71  // Leaky sum of squares of parameter gradient.
72  meanSquaredGradient = arma::zeros<arma::mat>(rows, cols);
73  }
74 
82  void Update(arma::mat& iterate,
83  const double stepSize,
84  const arma::mat& gradient)
85  {
86  meanSquaredGradient *= alpha;
87  meanSquaredGradient += (1 - alpha) * (gradient % gradient);
88  iterate -= stepSize * gradient / (arma::sqrt(meanSquaredGradient) +
89  epsilon);
90  }
91 
93  double Epsilon() const { return epsilon; }
95  double& Epsilon() { return epsilon; }
96 
98  double Alpha() const { return alpha; }
100  double& Alpha() { return alpha; }
101 
102  private:
103  // The epsilon value used to initialise the squared gradient parameter.
104  double epsilon;
105 
106  // The smoothing parameter.
107  double alpha;
108 
109  // Leaky sum of squares of parameter gradient.
110  arma::mat meanSquaredGradient;
111 };
112 
113 } // namespace optimization
114 } // namespace mlpack
115 
116 #endif
double Alpha() const
Get the smoothing parameter.
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
double & Alpha()
Modify the smoothing parameter.
double Epsilon() const
Get the value used to initialise the squared gradient parameter.
void Initialize(const size_t rows, const size_t cols)
The Initialize method is called by SGD Optimizer method before the start of the iteration update proc...
RMSProp is an optimizer that utilizes the magnitude of recent gradients to normalize the gradients...
RMSPropUpdate(const double epsilon=1e-8, const double alpha=0.99)
Construct the RMSProp update policy with the given parameters.
void Update(arma::mat &iterate, const double stepSize, const arma::mat &gradient)
Update step for RMSProp.
double & Epsilon()
Modify the value used to initialise the squared gradient parameter.