adagrad_optimizer.h 604 字节
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
  AdagradOptimizer(double epsilon, double decay, LrPolicy *lr)
11 12 13 14
      : ParameterOptimizer(lr),
        accum_gradient_(nullptr),
        epsilon_(epsilon),
        decay_(decay) {}
15
  ~AdagradOptimizer() {
D
dzhwinter 已提交
16
    if (accum_gradient_) delete accum_gradient_;
17
  }
D
dzhwinter 已提交
18
  void Update(const Tensor *gradient);
D
dzhwinter 已提交
19
  void set_weight(Tensor *p);
20 21

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

}  // namespace optimizer
}  // namespace paddle