adadelta_optimizer.h 830 字节
Newer Older
1 2 3 4 5 6 7 8
#ifndef PADDLE_ADADELTA_OPTIMIZER_H_
#define PADDLE_ADADELTA_OPTIMIZER_H_

#include "parameter_optimizer.h"

namespace paddle {
namespace optimizer {

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

private:
D
dzhwinter 已提交
23 24 25
  Tensor *accum_gradient_;
  Tensor *accum_delta_;
  Tensor *update_delta_;
26

D
dzhwinter 已提交
27 28 29
  double rho_;
  double epsilon_;
  double decay_;
30 31 32 33 34 35
};

}  // namespace optimizer
}  // namespace paddle

#endif