13 #ifndef MLPACK_CORE_OPTIMIZERS_ADAM_NADAM_UPDATE_HPP
14 #define MLPACK_CORE_OPTIMIZERS_ADAM_NADAM_UPDATE_HPP
19 namespace optimization {
50 const double beta1 = 0.9,
51 const double beta2 = 0.99,
52 const double scheduleDecay = 4e-3) :
56 scheduleDecay(scheduleDecay),
72 m = arma::zeros<arma::mat>(rows, cols);
73 v = arma::zeros<arma::mat>(rows, cols);
84 const double stepSize,
85 const arma::mat& gradient)
92 m += (1 - beta1) * gradient;
95 v += (1 - beta2) * gradient % gradient;
97 double beta1T = beta1 * (1 - (0.5 *
98 std::pow(0.96, iteration * scheduleDecay)));
100 double beta1T1 = beta1 * (1 - (0.5 *
101 std::pow(0.96, (iteration + 1) * scheduleDecay)));
105 const double biasCorrection1 = 1.0 - cumBeta1;
107 const double biasCorrection2 = 1.0 - std::pow(beta2, iteration);
109 const double biasCorrection3 = 1.0 - (cumBeta1 * beta1T1);
114 iterate -= (stepSize * (((1 - beta1T) / biasCorrection1) * gradient
115 + (beta1T1 / biasCorrection3) * m) * sqrt(biasCorrection2))
116 / (arma::sqrt(v) + epsilon);
130 double Beta1()
const {
return beta1; }
135 double Beta2()
const {
return beta2; }
161 double scheduleDecay;
double ScheduleDecay() const
Get the decay parameter for decay coefficients.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double & ScheduleDecay()
Modify the decay parameter for decay coefficients.
double & CumBeta1()
Modify the value of the cumulative product of decay coefficients.
double & Beta1()
Modify the smoothing parameter.
double CumBeta1() const
Get the value of the cumulative product of decay coefficients.
double & Epsilon()
Modify the value used to initialise the squared gradient parameter.
Nadam is an optimizer that combines the Adam and NAG optimization strategies.
void Initialize(const size_t rows, const size_t cols)
The Initialize() method is called by the optimizer before the start of the iteration update process...
double & Beta2()
Modify the second moment coefficient.
void Update(arma::mat &iterate, const double stepSize, const arma::mat &gradient)
Update step for Nadam.
double Beta1() const
Get the smoothing parameter.
NadamUpdate(const double epsilon=1e-8, const double beta1=0.9, const double beta2=0.99, const double scheduleDecay=4e-3)
Construct the Nadam update policy with the given parameters.
double Epsilon() const
Get the value used to initialise the squared gradient parameter.
double Beta2() const
Get the second moment coefficient.