15 #ifndef MLPACK_CORE_OPTIMIZERS_BIGBATCH_SGD_ADAPTIVE_STEPSIZE_HPP 16 #define MLPACK_CORE_OPTIMIZERS_BIGBATCH_SGD_ADAPTIVE_STEPSIZE_HPP 19 namespace optimization {
54 const double searchParameter = 0.1) :
55 backtrackStepSize(backtrackStepSize),
56 searchParameter(searchParameter)
74 template<
typename DecomposableFunctionType>
75 void Update(DecomposableFunctionType&
function,
78 const arma::mat& gradient,
79 const double gradientNorm,
80 const double sampleVariance,
82 const size_t batchSize,
83 const size_t backtrackingBatchSize,
86 Backtracking(
function, stepSize, iterate, gradient, gradientNorm, offset,
87 backtrackingBatchSize);
90 iterate -= stepSize * gradient;
92 double stepSizeDecay = 0;
93 if (batchSize <
function.NumFunctions())
95 stepSizeDecay = (1 - (1 / ((double) batchSize - 1) * sampleVariance) /
96 (batchSize * gradientNorm)) / batchSize;
100 stepSizeDecay = 1 /
function.NumFunctions();
104 stepSize *= (1 - ((double) batchSize /
function.NumFunctions()));
105 stepSize += stepSizeDecay * ((double) batchSize /
function.NumFunctions());
107 Backtracking(
function, stepSize, iterate, gradient, gradientNorm, offset,
108 backtrackingBatchSize);
136 template<
typename DecomposableFunctionType>
137 void Backtracking(DecomposableFunctionType&
function,
139 const arma::mat& iterate,
140 const arma::mat& gradient,
141 const double gradientNorm,
143 const size_t backtrackingBatchSize)
145 double overallObjective =
function.Evaluate(iterate, offset,
146 backtrackingBatchSize);
148 arma::mat iterateUpdate = iterate - (stepSize * gradient);
149 double overallObjectiveUpdate =
function.Evaluate(iterateUpdate, offset,
150 backtrackingBatchSize);
152 while (overallObjectiveUpdate >
153 (overallObjective + searchParameter * stepSize * gradientNorm))
155 stepSize *= backtrackStepSize;
157 iterateUpdate = iterate - (stepSize * gradient);
158 overallObjectiveUpdate =
function.Evaluate(iterateUpdate, offset,
159 backtrackingBatchSize);
164 double backtrackStepSize;
167 double searchParameter;
173 #endif // MLPACK_CORE_OPTIMIZERS_BIGBATCH_SGD_ADAPTIVE_STEPSIZE_HPP Definition of the adaptive stepize technique, a non-monotonic stepsize scheme that uses curvature est...
AdaptiveStepsize(const double backtrackStepSize=0.1, const double searchParameter=0.1)
Construct the AdaptiveStepsize object with the given function and parameters.
double BacktrackStepSize() const
Get the backtracking step size.
double & BacktrackStepSize()
Modify the backtracking step size.
double SearchParameter() const
Get the search parameter.
void Update(DecomposableFunctionType &function, double &stepSize, arma::mat &iterate, const arma::mat &gradient, const double gradientNorm, const double sampleVariance, const size_t offset, const size_t batchSize, const size_t backtrackingBatchSize, const bool)
This function is called in each iteration.
double & SearchParameter()
Modify the search parameter.