1 #ifndef OPTIMIZER_H_
2 #define OPTIMIZER_H_
3 
4 #include <Eigen/Core>
5 #include "Config.h"
6 
7 namespace MiniDNN
8 {
9 
10 
11 ///
12 /// \defgroup Optimizers Optimization Algorithms
13 ///
14 
15 ///
16 /// \ingroup Optimizers
17 ///
18 /// The interface of optimization algorithms
19 ///
20 class Optimizer
21 {
22     protected:
23         typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
24         typedef Vector::ConstAlignedMapType ConstAlignedMapVec;
25         typedef Vector::AlignedMapType AlignedMapVec;
26 
27     public:
~Optimizer()28         virtual ~Optimizer() {}
29 
30         ///
31         /// Reset the optimizer to clear all historical information
32         ///
reset()33         virtual void reset() {};
34 
35         ///
36         /// Update the parameter vector using its gradient
37         ///
38         /// It is assumed that the memory addresses of `dvec` and `vec` do not
39         /// change during the training process. This is used to implement optimization
40         /// algorithms that have "memories". See the AdaGrad algorithm for an example.
41         ///
42         /// \param dvec The gradient of the parameter. Read-only
43         /// \param vec  On entering, the current parameter vector. On exit, the
44         ///             updated parameters.
45         ///
46         virtual void update(ConstAlignedMapVec& dvec, AlignedMapVec& vec) = 0;
47 };
48 
49 
50 } // namespace MiniDNN
51 
52 
53 #endif /* OPTIMIZER_H_ */
54