adagrad_optimizer.h 582 字节
Newer Older
D
dzhwinter 已提交
1
#pragma once
2 3 4 5 6 7

#include "parameter_optimizer.h"

namespace paddle {
namespace optimizer {

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

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

}  // namespace optimizer
}  // namespace paddle