adadelta_optimizer.h 853 字节
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 AdadeltaOptimizer : public ParameterOptimizer {
9
public:
D
dzhwinter 已提交
10
  AdadeltaOptimizer(double rho, double epsilon, double decay, LrPolicy *lr)
11 12 13 14 15 16 17
      : ParameterOptimizer(lr),
        accum_gradient_(nullptr),
        accum_delta_(nullptr),
        update_delta_(nullptr),
        rho_(rho),
        epsilon_(epsilon),
        decay_(decay) {}
18
  ~AdadeltaOptimizer() {
D
dzhwinter 已提交
19 20 21
    if (accum_gradient_) delete accum_gradient_;
    if (accum_delta_) delete accum_delta_;
    if (update_delta_) delete update_delta_;
22
  }
D
dzhwinter 已提交
23
  void Update(const Tensor *gradient);
D
dzhwinter 已提交
24
  void set_weight(Tensor *p);
25 26

private:
D
dzhwinter 已提交
27 28 29 30 31 32
  Tensor *accum_gradient_;
  Tensor *accum_delta_;
  Tensor *update_delta_;
  double rho_;
  double epsilon_;
  double decay_;
33 34 35 36
};

}  // namespace optimizer
}  // namespace paddle