adagrad_optimizer.h 640 字节
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:
11
  AdagradOptimizer(double epsilon, double decay, BaseLr *lr)
D
dzhwinter 已提交
12
      : ParameterOptimizer(lr), epsilon(epsilon), decay(decay) {}
13 14 15
  ~AdagradOptimizer() {
    if (accum_gradient) delete accum_gradient;
  }
D
dzhwinter 已提交
16 17 18
  void update(const Tensor &gradient);
  void set_weight(Tensor *p);
  real *get_weight() const;
19 20

private:
D
dzhwinter 已提交
21
  Tensor *accum_gradient;
22 23 24 25 26 27 28 29
  double epsilon;
  double decay;
};

}  // namespace optimizer
}  // namespace paddle

#endif