regularizer.h 787 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#ifndef PADDLE_OPITMIZER_REGULARIZER_H_
#define PADDLE_OPTIMIZER_REGULARIZER_H_

#include "OptimizerConfig.pb.h"
#include "Tensor.h"

namespace paddle {
namespace optimizer {

/**
 * @brief regularizer in L1, L2
 */

template <class T>
class Regularizer {
public:
  /**
   *  @brief regularizer update interface
   *  @param param need to update
   *  @return void
   */
  static Regularizer *create(const std::string &config);
  virtual void update(Tensor<T> &parameter) = 0;

private:
  std::string regularizer_name;
  OptimizerConfig config_;
};

template <class T>
class L1Regularizer {
public:
  void update(Tensor<T> &parameter);
};

template <class T>
class L2Regularizer {
public:
  void update(Tensor<T> &parameter);
};

}  // namespace optimizer
}  // namespace paddle

#endif