AIToolbox
A library that offers tools for AI problem solving.
Adam.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_ADAM_HEADER_FILE
2 #define AI_TOOLBOX_ADAM_HEADER_FILE
3 
4 #include <AIToolbox/Types.hpp>
5 
6 namespace AIToolbox {
23  class Adam {
24  public:
41  Adam(AIToolbox::Vector * point, const AIToolbox::Vector & gradient, double alpha = 0.001, double beta1 = 0.9, double beta2 = 0.999, double epsilon = 1e-8);
42 
52  void step();
53 
62  void reset();
63 
72  void reset(AIToolbox::Vector * point, const AIToolbox::Vector & gradient);
73 
77  void setAlpha(double alpha);
78 
82  void setBeta1(double beta1);
83 
87  void setBeta2(double beta2);
88 
92  void setEpsilon(double epsilon);
93 
97  double getAlpha() const;
98 
102  double getBeta1() const;
103 
107  double getBeta2() const;
108 
112  double getEpsilon() const;
113 
114  private:
115  AIToolbox::Vector * point_;
116  const AIToolbox::Vector * gradient_;
117  AIToolbox::Vector m_, v_;
118 
119  double beta1_, beta2_, alpha_, epsilon_;
120  unsigned step_;
121  };
122 }
123 
124 #endif
AIToolbox::Adam::setAlpha
void setAlpha(double alpha)
This function sets the current learning rate.
AIToolbox::Adam::getEpsilon
double getEpsilon() const
This function returns the current additive division parameter.
AIToolbox::Adam::setBeta1
void setBeta1(double beta1)
This function sets the current exponential decay rate for first moment estimates.
AIToolbox::Adam::setEpsilon
void setEpsilon(double epsilon)
This function sets the current additive division parameter.
AIToolbox::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Definition: Types.hpp:16
AIToolbox::Adam::getBeta2
double getBeta2() const
This function returns the current exponential decay rate for second moment estimates.
AIToolbox::Adam::Adam
Adam(AIToolbox::Vector *point, const AIToolbox::Vector &gradient, double alpha=0.001, double beta1=0.9, double beta2=0.999, double epsilon=1e-8)
Basic constructor.
AIToolbox::Adam::setBeta2
void setBeta2(double beta2)
This function sets the current exponential decay rate for second moment estimates.
AIToolbox
Definition: Experience.hpp:6
Types.hpp
AIToolbox::Adam::reset
void reset()
This function resets the gradient descent process.
AIToolbox::Adam
This class implements the ADAM gradient descent algorithm.
Definition: Adam.hpp:23
AIToolbox::Adam::step
void step()
This function updates the point using the currently set gradient.
AIToolbox::Adam::getAlpha
double getAlpha() const
This function returns the current learning rate.
AIToolbox::Adam::getBeta1
double getBeta1() const
This function returns the current exponential decay rate for first moment estimates.