Minor changes addressing review comments

This commit is contained in:
Vivek Pal
2017-03-30 00:57:15 +05:30
parent b057f881ab
commit 81b8d03faf
3 changed files with 16 additions and 22 deletions
+5 -13
View File
@@ -34,6 +34,7 @@ namespace optimization {
* author = {Simon Funk},
* title = {RMSprop loses to SMORMS3 - Beware the Epsilon!},
* year = {2015}
* url = {http://sifter.org/~simon/journal/20150420.html}
* }
* @endcode
*
@@ -97,9 +98,9 @@ class SMORMS3
double Optimize(arma::mat& iterate) { return optimizer.Optimize(iterate); }
//! Get the instantiated function to be optimized.
const DecomposableFunctionType& Function() const { return function; }
const DecomposableFunctionType& Function() const { return optimizer.Function(); }
//! Modify the instantiated function.
DecomposableFunctionType& Function() { return function; }
DecomposableFunctionType& Function() { return optimizer.Function(); }
//! Get the step size.
double StepSize() const { return optimizer.StepSize(); }
@@ -107,9 +108,9 @@ class SMORMS3
double& StepSize() { return optimizer.StepSize(); }
//! Get the value used to initialise the mean squared gradient parameter.
double Epsilon() const { return smorms3Update.Epsilon(); }
double Epsilon() const { return optimizer.UpdatePolicy().Epsilon(); }
//! Modify the value used to initialise the mean squared gradient parameter.
double& Epsilon() { return smorms3Update.Epsilon(); }
double& Epsilon() { return optimizer.UpdatePolicy().Epsilon(); }
//! Get the maximum number of iterations (0 indicates no limit).
size_t MaxIterations() const { return optimizer.MaxIterations(); }
@@ -127,15 +128,6 @@ class SMORMS3
bool& Shuffle() { return optimizer.Shuffle(); }
private:
//! The instantiated function.
DecomposableFunctionType& function;
//! The value used to initialise the mean squared gradient parameter.
double epsilon;
//! The SMORMS3Update update policy object.
SMORMS3Update smorms3Update;
//! The Stochastic Gradient Descent object with SMORMS3Update update policy.
SGD<DecomposableFunctionType, SMORMS3Update> optimizer;
};
@@ -25,15 +25,12 @@ SMORMS3<DecomposableFunctionType>::SMORMS3(DecomposableFunctionType& function,
const size_t maxIterations,
const double tolerance,
const bool shuffle) :
function(function),
epsilon(epsilon),
smorms3Update(epsilon),
optimizer(function,
stepSize,
maxIterations,
tolerance,
shuffle,
smorms3Update)
SMORMS3Update(epsilon))
{ /* Nothing to do. */ }
} // namespace optimization
@@ -29,6 +29,7 @@ namespace optimization {
* author = {Simon Funk},
* title = {RMSprop loses to SMORMS3 - Beware the Epsilon!},
* year = {2015}
* url = {http://sifter.org/~simon/journal/20150420.html}
* }
* @endcode
*/
@@ -42,8 +43,8 @@ class SMORMS3Update
* @param epsilon Value used to initialise the mean squared gradient parameter.
*/
SMORMS3Update(const double epsilon = 1e-16) :
epsilon(epsilon),
previousStepSize(0)
epsilon(epsilon),
previousStepSize(0)
{ /* Do nothing. */ }
//! Get the value used to initialise the mean squared gradient parameter.
@@ -96,20 +97,24 @@ class SMORMS3Update
if (stepSize != previousStepSize)
{
stepSizeMat.fill(stepSize);
previousStepSize = stepSize;
}
iterate -= gradient % arma::min(x, stepSizeMat) / (arma::sqrt(g2) + epsilon);
mem %= (1 - x);
mem += 1;
previousStepSize = stepSize;
}
private:
//! The value used to initialise the mean squared gradient parameter.
double epsilon, previousStepSize;
double epsilon;
//! The previous value of step size in each iteration of update step.
double previousStepSize;
// The parameters mem, g and g2.
arma::mat mem, g, g2;
// The matrix to be filled with stepSize.
arma::mat stepSizeMat;
};