13 #ifndef MLPACK_CORE_OPTIMIZERS_ADAM_OPTIMISTICADAM_UPDATE_HPP 14 #define MLPACK_CORE_OPTIMIZERS_ADAM_OPTIMISTICADAM_UPDATE_HPP 19 namespace optimization {
53 const double beta1 = 0.9,
54 const double beta2 = 0.999) :
72 m = arma::zeros<arma::mat>(rows, cols);
73 v = arma::zeros<arma::mat>(rows, cols);
74 g = arma::zeros<arma::mat>(rows, cols);
85 const double stepSize,
86 const arma::mat& gradient)
93 m += (1 - beta1) * gradient;
96 v += (1 - beta2) * arma::square(gradient);
98 arma::mat mCorrected = m / (1.0 - std::pow(beta1, iteration));
99 arma::mat vCorrected = v / (1.0 - std::pow(beta2, iteration));
101 arma::mat update = mCorrected / (arma::sqrt(vCorrected) + epsilon);
103 iterate -= (2 * stepSize * update - stepSize * g);
105 g = std::move(update);
114 double Beta1()
const {
return beta1; }
119 double Beta2()
const {
return beta2; }
double & Epsilon()
Modify the value used to initialize the squared gradient parameter.
void Initialize(const size_t rows, const size_t cols)
The Initialize method is called by SGD Optimizer method before the start of the iteration update proc...
double & Beta2()
Modify the second moment coefficient.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double & Beta1()
Modify the smoothing parameter.
OptimisticAdamUpdate(const double epsilon=1e-8, const double beta1=0.9, const double beta2=0.999)
Construct the OptimisticAdam update policy with the given parameters.
void Update(arma::mat &iterate, const double stepSize, const arma::mat &gradient)
Update step for OptimisticAdam.
double Beta1() const
Get the smoothing parameter.
double Epsilon() const
Get the value used to initialize the squared gradient parameter.
OptimisticAdam is an optimizer which implements the Optimistic Adam algorithm which uses Optmistic Mi...
double Beta2() const
Get the second moment coefficient.