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

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

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

}  // namespace optimizer
}  // namespace paddle