mlpack  git-master
SPALeRASGD< DecayPolicyType > Class Template Reference

SPALeRA Stochastic Gradient Descent is a technique for minimizing a function which can be expressed as a sum of other functions. More...

Public Member Functions

 SPALeRASGD (const double stepSize=0.01, const size_t batchSize=32, const size_t maxIterations=100000, const double tolerance=1e-5, const double lambda=0.01, const double alpha=0.001, const double epsilon=1e-6, const double adaptRate=3.10e-8, const bool shuffle=true, const DecayPolicyType &decayPolicy=DecayPolicyType(), const bool resetPolicy=true)
 Construct the SPALeRASGD optimizer with the given function and parameters. More...

 
double AdaptRate () const
 Get the agnostic learning rate update rate. More...

 
double & AdaptRate ()
 Modify the agnostic learning rate update rate. More...

 
double Alpha () const
 Get the tolerance for termination. More...

 
double & Alpha ()
 Modify the tolerance for termination. More...

 
size_t BatchSize () const
 Get the batch size. More...

 
size_t & BatchSize ()
 Modify the batch size. More...

 
DecayPolicyType DecayPolicy () const
 Get the decay policy. More...

 
DecayPolicyType & DecayPolicy ()
 Modify the decay policy. More...

 
size_t MaxIterations () const
 Get the maximum number of iterations (0 indicates no limit). More...

 
size_t & MaxIterations ()
 Modify the maximum number of iterations (0 indicates no limit). More...

 
template
<
typename
DecomposableFunctionType
>
double Optimize (DecomposableFunctionType &function, arma::mat &iterate)
 Optimize the given function using SPALeRA SGD. More...

 
bool ResetPolicy () const
 Get whether or not the update policy parameters are reset before Optimize call. More...

 
bool & ResetPolicy ()
 Modify whether or not the update policy parameters are reset before Optimize call. More...

 
bool Shuffle () const
 Get whether or not the individual functions are shuffled. More...

 
bool & Shuffle ()
 Modify whether or not the individual functions are shuffled. More...

 
double StepSize () const
 Get the step size. More...

 
double & StepSize ()
 Modify the step size. More...

 
double Tolerance () const
 Get the tolerance for termination. More...

 
double & Tolerance ()
 Modify the tolerance for termination. More...

 
SPALeRAStepsize UpdatePolicy () const
 Get the update policy. More...

 
SPALeRAStepsizeUpdatePolicy ()
 Modify the update policy. More...

 

Detailed Description


template
<
typename
DecayPolicyType
=
NoDecay
>

class mlpack::optimization::SPALeRASGD< DecayPolicyType >

SPALeRA Stochastic Gradient Descent is a technique for minimizing a function which can be expressed as a sum of other functions.

That is, suppose we have

\[ f(A) = \sum_{i = 0}^{n} f_i(A) \]

and our task is to minimize $ A $. SPALeRA SGD iterates over batches of functions $ \{ f_{i0}(A), f_{i1}(A), \ldots, f_{i(m - 1)}(A) $ for some batch size $ m $, producing the following update scheme:

\[ A_{j + 1} = A_j + \alpha \left(\sum_{k = 0}^{m - 1} \nabla f_{ik}(A) \right) \]

where $ \alpha $ is a parameter which specifies the step size. Each batch is passed through either sequentially or randomly. The algorithm continues until $ j $ reaches the maximum number of iterations—or when a full sequence of updates through each of the batches produces an improvement within a certain tolerance $ \epsilon $.

The parameter $ \epsilon $ is specified by the tolerance parameter tot he constructor, as is the maximum number of iterations specified by the maxIterations parameter.

This class is useful for data-dependent functions whose objective function can be expressed as a sum of objective functions operating on an individual point. Then, SPALeRA SGD considers the gradient of the objective function operation on an individual batches in its update of $ A $.

For more information, please refer to:

@misc{Schoenauer2017,
title = {Stochastic Gradient Descent:
Going As Fast As Possible But Not Faster},
author = {Schoenauer-Sebag, Alice; Schoenauer, Marc; Sebag, Michele},
journal = {CoRR},
year = {2017},
url = {https://arxiv.org/abs/1709.01427},
}

For SPALeRA SGD to work, the lass must implement the following function:

size_t NumFunctions(); double Evaluate(const arma::mat& coordinates, const size_t i); void Gradient(const arma::mat& coordinates, const size_t i, arma::mat& gradient);

NumFunctions() should return the number of functions, and in the other two functions, the parameter i refers to which individual function (or gradient) is being evaluated. So, for the case of a data-dependent function, such as NCA (see mlpack::nca::NCA), NumFunctions() should return the number of points in the dataset, and Evaluate(coordinates, 0) will evaluate the objective function on the first point in the dataset (presumably, the dataset is held internally in the DecomposableFunctionType).

Template Parameters
DecayPolicyTypeDecay policy used during the iterative update process to adjust the step size. By default the step size isn't going to be adjusted.

Definition at line 88 of file spalera_sgd.hpp.

Constructor & Destructor Documentation

◆ SPALeRASGD()

SPALeRASGD ( const double  stepSize = 0.01,
const size_t  batchSize = 32,
const size_t  maxIterations = 100000,
const double  tolerance = 1e-5,
const double  lambda = 0.01,
const double  alpha = 0.001,
const double  epsilon = 1e-6,
const double  adaptRate = 3.10e-8,
const bool  shuffle = true,
const DecayPolicyType &  decayPolicy = DecayPolicyType(),
const bool  resetPolicy = true 
)

Construct the SPALeRASGD optimizer with the given function and parameters.

The defaults here are not necessarily good for the given problem, so it is suggested that the values used be tailored to the task at hand. The maximum number of iterations refers to the maximum number of points that are processed (i.e., one iteration equals one point; one iteration does not equal one pass over the dataset).

Parameters
stepSizeStep size for each iteration.
batchSizeBatch size to use for each step.
maxIterationsMaximum number of iterations allowed (0 means no limit).
toleranceMaximum absolute tolerance to terminate algorithm.
lambdaPage-Hinkley update parameter.
alphaMemory parameter of the Agnostic Learning Rate adaptation.
epsilonNumerical stability parameter.
adaptRateAgnostic learning rate update rate.
shuffleIf true, the function order is shuffled; otherwise, each function is visited in linear order.
decayPolicyInstantiated decay policy used to adjust the step size.
resetPolicyFlag that determines whether update policy parameters are reset before every Optimize call.

Member Function Documentation

◆ AdaptRate() [1/2]

double AdaptRate ( ) const
inline

Get the agnostic learning rate update rate.

Definition at line 165 of file spalera_sgd.hpp.

References SPALeRAStepsize::AdaptRate().

◆ AdaptRate() [2/2]

double& AdaptRate ( )
inline

Modify the agnostic learning rate update rate.

Definition at line 167 of file spalera_sgd.hpp.

References SPALeRAStepsize::AdaptRate().

◆ Alpha() [1/2]

double Alpha ( ) const
inline

Get the tolerance for termination.

Definition at line 160 of file spalera_sgd.hpp.

References SPALeRAStepsize::Alpha().

◆ Alpha() [2/2]

double& Alpha ( )
inline

Modify the tolerance for termination.

Definition at line 162 of file spalera_sgd.hpp.

References SPALeRAStepsize::Alpha().

◆ BatchSize() [1/2]

size_t BatchSize ( ) const
inline

Get the batch size.

Definition at line 140 of file spalera_sgd.hpp.

◆ BatchSize() [2/2]

size_t& BatchSize ( )
inline

Modify the batch size.

Definition at line 142 of file spalera_sgd.hpp.

◆ DecayPolicy() [1/2]

DecayPolicyType DecayPolicy ( ) const
inline

Get the decay policy.

Definition at line 187 of file spalera_sgd.hpp.

◆ DecayPolicy() [2/2]

DecayPolicyType& DecayPolicy ( )
inline

Modify the decay policy.

Definition at line 189 of file spalera_sgd.hpp.

◆ MaxIterations() [1/2]

size_t MaxIterations ( ) const
inline

Get the maximum number of iterations (0 indicates no limit).

Definition at line 150 of file spalera_sgd.hpp.

◆ MaxIterations() [2/2]

size_t& MaxIterations ( )
inline

Modify the maximum number of iterations (0 indicates no limit).

Definition at line 152 of file spalera_sgd.hpp.

◆ Optimize()

double Optimize ( DecomposableFunctionType &  function,
arma::mat &  iterate 
)

Optimize the given function using SPALeRA SGD.

The given starting point will be modified to store the finishing point of the algorithm, and the final objective value is returned.

Template Parameters
DecomposableFunctionTypeType of the function to be optimized.
Parameters
functionFunction to optimize.
iterateStarting point (will be modified).
Returns
Objective value of the final point.

◆ ResetPolicy() [1/2]

bool ResetPolicy ( ) const
inline

Get whether or not the update policy parameters are reset before Optimize call.

Definition at line 176 of file spalera_sgd.hpp.

◆ ResetPolicy() [2/2]

bool& ResetPolicy ( )
inline

Modify whether or not the update policy parameters are reset before Optimize call.

Definition at line 179 of file spalera_sgd.hpp.

◆ Shuffle() [1/2]

bool Shuffle ( ) const
inline

Get whether or not the individual functions are shuffled.

Definition at line 170 of file spalera_sgd.hpp.

◆ Shuffle() [2/2]

bool& Shuffle ( )
inline

Modify whether or not the individual functions are shuffled.

Definition at line 172 of file spalera_sgd.hpp.

◆ StepSize() [1/2]

double StepSize ( ) const
inline

Get the step size.

Definition at line 145 of file spalera_sgd.hpp.

◆ StepSize() [2/2]

double& StepSize ( )
inline

Modify the step size.

Definition at line 147 of file spalera_sgd.hpp.

◆ Tolerance() [1/2]

double Tolerance ( ) const
inline

Get the tolerance for termination.

Definition at line 155 of file spalera_sgd.hpp.

◆ Tolerance() [2/2]

double& Tolerance ( )
inline

Modify the tolerance for termination.

Definition at line 157 of file spalera_sgd.hpp.

◆ UpdatePolicy() [1/2]

SPALeRAStepsize UpdatePolicy ( ) const
inline

Get the update policy.

Definition at line 182 of file spalera_sgd.hpp.

◆ UpdatePolicy() [2/2]

SPALeRAStepsize& UpdatePolicy ( )
inline

Modify the update policy.

Definition at line 184 of file spalera_sgd.hpp.


The documentation for this class was generated from the following file:
  • /var/www/www.mlpack.org/mlpack-git/src/mlpack/core/optimizers/spalera_sgd/spalera_sgd.hpp