adagrad_optimizer.h 649 字节
Newer Older
1 2 3 4 5 6 7 8
#ifndef PADDLE_ADAGRAD_OPTIMIZER_H_
#define PADDLE_ADAGRAD_OPTIMIZER_H_

#include "parameter_optimizer.h"

namespace paddle {
namespace optimizer {

D
dzhwinter 已提交
9
class AdagradOptimizer : public ParameterOptimizer {
10
public:
D
dzhwinter 已提交
11 12
  AdagradOptimizer(double epsilon, double decay, LrPolicy *lr)
      : ParameterOptimizer(lr), epsilon_(epsilon), decay_(decay) {}
13
  ~AdagradOptimizer() {
D
dzhwinter 已提交
14
    if (accum_gradient_) delete accum_gradient_;
15
  }
D
dzhwinter 已提交
16
  void Update(const Tensor *gradient);
D
dzhwinter 已提交
17 18
  void set_weight(Tensor *p);
  real *get_weight() const;
19 20

private:
D
dzhwinter 已提交
21 22 23
  Tensor *accum_gradient_;
  double epsilon_;
  double decay_;
24 25 26 27 28 29
};

}  // namespace optimizer
}  // namespace paddle

#endif