OpenANN  1.1.0
An open source library for artificial neural networks.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MBSGD.h
Go to the documentation of this file.
1 #ifndef OPENANN_OPTIMIZATION_MBSGD_H_
2 #define OPENANN_OPTIMIZATION_MBSGD_H_
3 
6 #include <OpenANN/util/Random.h>
7 #include <Eigen/Core>
8 #include <vector>
9 #include <list>
10 
11 namespace OpenANN
12 {
13 
116 class MBSGD : public Optimizer
117 {
119  StoppingCriteria stop;
121  Optimizable* opt; // do not delete
123  bool nesterov;
125  double alpha;
127  double alphaDecay;
129  double minAlpha;
131  double eta;
133  double etaGain;
135  double maxEta;
137  int batchSize;
139  double minGain;
141  double maxGain;
143  bool useGain;
144 
145  int iteration;
147  int P, N, batches;
148  Eigen::VectorXd gradient, gains, parameters, momentum, currentGradient;
149  double accumulatedError;
150  std::vector<int> randomIndices;
151 public:
170  MBSGD(double learningRate = 0.01, double momentum = 0.5, int batchSize = 10,
171  bool nesterov = false, double learningRateDecay = 1.0,
172  double minimalLearningRate = 0.0, double momentumGain = 0.0,
173  double maximalMomentum = 1.0, double minGain = 1.0,
174  double maxGain = 1.0);
175  ~MBSGD();
176  virtual void setOptimizable(Optimizable& opt);
177  virtual void setStopCriteria(const StoppingCriteria& stop);
178  virtual void optimize();
179  virtual bool step();
180  virtual Eigen::VectorXd result();
181  virtual std::string name();
182 private:
183  void initialize();
184 };
185 
186 } // namespace OpenANN
187 
188 #endif // OPENANN_OPTIMIZATION_MBSGD_H_