13 #ifndef MLPACK_CORE_OPTIMIZERS_ADAM_NADAMAX_UPDATE_HPP 14 #define MLPACK_CORE_OPTIMIZERS_ADAM_NADAMAX_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 u = arma::zeros<arma::mat>(rows, cols);
84 const double stepSize,
85 const arma::mat& gradient)
92 m += (1 - beta1) * gradient;
94 u = arma::max(u * beta2, arma::abs(gradient));
96 double beta1T = beta1 * (1 - (0.5 *
97 std::pow(0.96, iteration * scheduleDecay)));
99 double beta1T1 = beta1 * (1 - (0.5 *
100 std::pow(0.96, (iteration + 1) * scheduleDecay)));
104 const double biasCorrection1 = 1.0 - cumBeta1;
106 const double biasCorrection2 = 1.0 - (cumBeta1 * beta1T1);
108 if ((biasCorrection1 != 0) && (biasCorrection2 != 0))
110 iterate -= (stepSize * (((1 - beta1T) / biasCorrection1) * gradient
111 + (beta1T1 / biasCorrection2) * m)) / (u + epsilon);
126 double Beta1()
const {
return beta1; }
131 double Beta2()
const {
return beta2; }
157 double scheduleDecay;
double ScheduleDecay() const
Get the decay parameter for decay coefficients.
double Epsilon() const
Get the value used to initialise the squared gradient parameter.
NadaMaxUpdate(const double epsilon=1e-8, const double beta1=0.9, const double beta2=0.99, const double scheduleDecay=4e-3)
Construct the NadaMax update policy with the given parameters.
void Update(arma::mat &iterate, const double stepSize, const arma::mat &gradient)
Update step for NadaMax.
double & CumBeta1()
Modify the value of the cumulative product of decay coefficients.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double & Epsilon()
Modify the value used to initialise the squared gradient parameter.
double & Beta1()
Modify the smoothing parameter.
double & ScheduleDecay()
Modify the decay parameter for decay coefficients.
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() const
Get the second moment coefficient.
double CumBeta1() const
Get the value of the cumulative product of decay coefficients.
double Beta1() const
Get the smoothing parameter.
double & Beta2()
Modify the second moment coefficient.
NadaMax is an optimizer that combines the AdaMax and NAG.