adadelta_optimizer.h 940 字节
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 13
  using ParameterOptimizer::parameter_;
  using ParameterOptimizer::num_sample_passed;
  using ParameterOptimizer::lr_policy;
14 15

  AdadeltaOptimizer(double rho, double epsilon, double decay, BaseLr *lr)
D
dzhwinter 已提交
16
      : ParameterOptimizer(lr), rho(rho), epsilon(epsilon), decay(decay) {}
17 18 19 20 21
  ~AdadeltaOptimizer() {
    if (accum_gradient) delete accum_gradient;
    if (accum_delta) delete accum_delta;
    if (update_delta) delete update_delta;
  }
D
dzhwinter 已提交
22 23 24
  void update(const Tensor &gradient);
  void set_weight(Tensor *p);
  real *get_weight() const;
25 26

private:
D
dzhwinter 已提交
27 28 29
  Tensor *accum_gradient;
  Tensor *accum_delta;
  Tensor *update_delta;
30 31 32 33 34 35 36 37 38 39

  double rho;
  double epsilon;
  double decay;
};

}  // namespace optimizer
}  // namespace paddle

#endif